mysql下建立账号并授予所有权限

create user ‘kugou’@’%’ identified by ‘Kug0u@db’;
其中kugou为用户。%:匹配全部主机,该地方还能够设置成‘localhost’,表明只能本地访问,例如root帐户默认为‘localhost‘
Kug0u@db为密码。mysql

grant select,insert,update,delete,create on [数据库名称].* to [用户名称];–用户受权数据库
*表明整个数据库web

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’;–删除用户sql

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;查看账号权限ide