1.進入到mysql數據庫下
mysql>use mysql;
2.創建新用戶
指定ip為192.168.1.1的operationCenterAdmin用戶登錄
create user ‘operationCenterAdmin’@‘192.168.1.1’ identified by '123456';
指定ip為192.168.1.開頭的operationCenterAdmin用戶登錄
create user 'operationCenterAdmin'@'192.118.1.%' identified by '123456';
指定任何ip的operationCenterAdmin用戶登錄
create use 'operationCenterAdmin'@'%' identified by '123456';
3.授權
grant select on 數據庫名.表名 to "operationCenterAdmin’"@'%';
eg:grant select on mis.* to "operationCenterAdmin’"@'%';
4.更新權限
flush privileges;
技能補充:
1.刪除用戶
drop user '用戶名'@'IP地址';
2.修改用戶
rename user '用戶名'@'IP地址' to '新用戶名'@'IP地址';
3.修改密碼
set password for '用戶名'@'IP地址'=Password('新密碼');
4.查看用戶權限
show grants for '用戶'@'IP地址'
5.授權
grant select ,insert,update on db1.t1 to "用戶名"@'%';
5.1授予所有權限,除了grant這個命令,這個命令是root才有的
grant all privileges on db1.t1 to "用戶名"@'%';
6.取消權限
取消來自遠程服務器的operationCenterAdmin用戶對數據庫db1的所有表的所有權限
revoke all on db1.* from 'operationCenterAdmin'@"%";
取消來自遠程服務器的operationCenterAdmin用戶所有數據庫的所有的表的權限
revoke all privileges on '*' from 'operationCenterAdmin'@'%';