//create user 用户名@指定ip identified by 密码;
create user test123@localhost IDENTIFIED by 'test123';
//create user 用户名@客户端ip identified by 密码; 指定IP才能登陆
create user test456@10.4.10.18 IDENTIFIED by 'test456';
//create user 用户名@‘% ’ identified by 密码 任意IP均可登陆
create user test7@'%' IDENTIFIED by 'test7'
2. 用户授权
//1. 给指定用户授予指定指定数据库指定权限
//grant 权限1,权限2,........,权限n on
数据库名.* to 用户名@IP;
grant select,insert,update,delete,create on
chaoshi.* to 'test456'@'127.0.0.1';
//2. 给指定用户授予所有数据库所有权限
//grant all on . to 用户名@IP
grant all on *.* to 'test456'@'127.0.0.1';
3. 用户权限查询
show grants for 用户名@IP;
show grants for 'root'@'%';
4. 撤销用户权限
//revoke 权限1,权限2,........,权限n on 数据库名.* from 用户名@IP;
REVOKE SELECT ON *.* FROM 'root'@'%' ;