create user ‘kugou’@’%’ identified by ‘Kug0u@db’;
其中kugou为用户。%:匹配所有主机,该地方还可以设置成‘localhost’,代表只能本地访问,例如root账户默认为‘localhost‘
Kug0u@db为密码。
grant select,insert,update,delete,create on [数据库名称].* to [用户名称];–用户授权数据库
*代表整个数据库
mysql> grant select,insert,update,delete,create on sys.* to kugou;
mysql> grant select,insert,update,delete,create on performance_schema.* to kugou;
mysql> grant select,insert,update,delete,create on mysql.* to kugou;
information_schema.数据库在创建用户时就拥有的权限。
mysql> flush privileges;
revoke all on . from kugou;–取消用户所有数据库(表)的所有权限
delete from mysql.user where user=‘kugou’;–删除用户
create user ‘dst’@’%’ identified by ‘dstyl!1’;
grant all privileges on . to ‘dst’@’%'identified by ‘dstyl!1’ with grant option; 可以给予全部权限
create user ‘dsttest’@’%’ identified by ‘dstt1!t’;
grant select on . to ‘dsttest’@’%'identified by 'dstt1!t’with grant option;
use mysql;
show grants for dsttest;查看帐号权限