轉(zhuǎn)自:https://www.cnblogs.com/zhaohaiyu/p/11459613.html
mysql> use mysql
Database changed
1.創(chuàng)建用戶
# 指定ip:192.118.1.1的chao用戶登錄 create user 'chao'@'192.118.1.1' identified by '123'; # 指定ip:192.118.1.開頭的chao用戶登錄 create user 'chao'@'192.118.1.%' identified by '123'; # 指定任何ip的chao用戶登錄 create user 'chao'@'%' identified by '123';
2.刪除用戶
drop user '用戶名'@'IP地址';
3.修改用戶
rename user '用戶名'@'IP地址' to '新用戶名'@'IP地址';
4.修改密碼
set password for '用戶名'@'IP地址'=Password('新密碼');
#查看權(quán)限 show grants for '用戶'@'IP地址' #授權(quán) chao用戶僅對(duì)db1.t1文件有查詢、插入和更新的操作 grant select ,insert,update on db1.t1 to "chao"@'%'; #授權(quán) chao用戶僅對(duì)db1文件有查詢的操作 grant select on db1.* to "chao"@'%'; # 表示有所有的權(quán)限,除了grant這個(gè)命令,這個(gè)命令是root才有的。chao用戶對(duì)db1下的t1文件有任意操作 grant all privileges on db1.t1 to "chao"@'%'; #chao用戶對(duì)db1數(shù)據(jù)庫中的文件執(zhí)行任何操作 grant all privileges on db1.* to "chao"@'%'; #chao用戶對(duì)所有數(shù)據(jù)庫中文件有任何操作 grant all privileges on *.* to "chao"@'%';
#取消權(quán)限 # 取消chao用戶對(duì)db1的t1文件的任意操作 revoke all on db1.t1 from 'chao'@"%"; # 取消來自遠(yuǎn)程服務(wù)器的chao用戶對(duì)數(shù)據(jù)庫db1的所有表的所有權(quán)限 revoke all on db1.* from 'chao'@"%"; 取消來自遠(yuǎn)程服務(wù)器的chao用戶所有數(shù)據(jù)庫的所有的表的權(quán)限 revoke all privileges on *.* from 'chao'@'%';
聯(lián)系客服