1、创建用户:
create user 用户名@xxx identified by 密码;
create user 用户名@指定ip identified by 密码; 指定IP才能登陆
create user 用户名@% identified by 密码 任意IP均可登陆
create user 'root'@'%' identified by '123456' with grant option;
加上with grant option; 表示可以给其他人授权。
2、用户授权:
grant 权限1,权限2,........,权限n on 数据库名.* to 用户名@IP; 给指定用户授予指定指定数据库指定权限
grant all on *.* to 用户名@IP 给指定用户授予所有数据库所有权限
grant all on *.* to 'root'@'%'
3、用户权限查询:
show grants for 用户名@IP;
show grants for 'root'@'%';
4、撤销用户权限:
revoke 权限1,权限2,........,权限n on 数据库名.* from 用户名@IP;
REVOKE SELECT ON *.* FROM 'root'@'%' ;
5、删除用户:
drop user 用户名@IP;