《MYSQL數(shù)據(jù)庫mysql 新增、刪除用戶和權(quán)限分配》要點:
本文介紹了MYSQL數(shù)據(jù)庫mysql 新增、刪除用戶和權(quán)限分配,希望對您有用。如果有疑問,可以聯(lián)系我們。
1. 新增用戶MYSQL數(shù)據(jù)庫
代碼如下:
mysql>insert into mysql.user(Host,User,Password) values("localhost","lionbule",password("hello1234"));
mysql>flush privileges;
2. 修改用戶密碼MYSQL數(shù)據(jù)庫
代碼如下:
mysql>update mysql.user set password=password('new password') where User="lionbule" and Host="localhost";
mysql>flush privileges;
3. 刪除用戶MYSQL數(shù)據(jù)庫
代碼如下:
mysql>DELETE FROM user WHERE User="lionbule" and Host="localhost";
mysql>flush privileges;
4. 權(quán)限分配MYSQL數(shù)據(jù)庫
??? 4.1. grant用法
?????????? grant 權(quán)限 on 數(shù)據(jù)庫.* to 用戶名@'登錄主機' identified by '密碼'MYSQL數(shù)據(jù)庫
代碼如下:
權(quán)限:
??? 常用總結(jié), ALL/ALTER/CREATE/DROP/SELECT/UPDATE/DELETE
數(shù)據(jù)庫:
???? *.*??????????????????? 表示所有庫的所有表
???? test.*??????????????? 表示test庫的所有表
???? test.test_table? 表示test庫的test_table表????
用戶名:
???? mysql賬戶名
登陸主機:
???? 允許登陸mysql server的客戶端ip
???? '%'表示所有ip
???? 'localhost' 表示本機
???? '192.168.10.2' 特定IP
密碼:
????? 賬戶對應(yīng)的登陸密碼
4.2 例子MYSQL數(shù)據(jù)庫
代碼如下:
mysql>grant all? on test.* to lionbule@'%' identified by 'hello1234';
mysql>flush privileges;
新增密碼為‘hello234'的用戶lionbule對test庫擁有所有操作權(quán)限,并不限制lionbule用戶的登陸IP.???? MYSQL數(shù)據(jù)庫
4.3 注意事項MYSQL數(shù)據(jù)庫
grant 會覆蓋用戶的部分信息,跟insert 、update執(zhí)行功能一樣. MYSQL數(shù)據(jù)庫
參考:
http://dev.mysql.com/doc/refman/5.6/en/grant.htmlMYSQL數(shù)據(jù)庫
轉(zhuǎn)載請注明本頁網(wǎng)址:
http://www.fzlkiss.com/jiaocheng/5001.html