操作mysql用戶,權限

MySQL 技術 白小石的IT刷怪祕籍 2017-05-25

操作mysql用戶,權限

1 ,創建用戶

create user '用戶名'@'允許登錄地址/服務器' identified by '密碼';

例子:

//本主機使用,其他主機登錄報錯

create user 'xiaobai'@'localhost' identified by '123';

//創建一個可以在本地和遠程都可以登陸的用戶,通配符%

create user 'unlimituser'@'%' identified by '123';

mysql -h192.168.40.11 -uunlimituser -p//遠程登錄

創建+權限

grant select,insert on *.* to 'xiaobai'@'192.168.10.128' identified by '123456';

2,刪除用戶

drop user '用戶名'@'允許登錄地址/服務器';

drop user 'xiaobai'@'localhost';

3 , 修改密碼

改root:set password =password('密碼123456');

遠程:set password from 'root'@'localhost'=password('123456');

改他人:set password for '用戶名'@'允許登錄地址/服務器' =password('密碼');

4,添加權限

grant 權限 on 對象 to 用戶 [with grant option]

--with grant option 表明用戶可以向其他

5,收回權限

revoke 權限 on from 用戶  [cascade constraints]

--cascade constraints表示取消用戶用此權限創建的所有

例子:revoke select,insert on *.* from 'xiaobai'@'192.168.10.28';

相關推薦

推薦中...