MySQL创建用户与授权

来源:互联网 发布:pid4占用80端口 编辑:程序博客网 时间:2024/03/29 15:50

1、建立用户,创建用户的时候不分配任何权限

create user '用户名'@‘访问’ identified by '密码';

2、删除用户

drop user '用户名';

3、分配权限

grant 权限 on 数据库.表 to  '用户名'@‘访问’ identified by '密码';

grant select, insert, update, delete on *.* to ‘root’@’%’ ;--分配基本权限

grant all privileges on *.* to ‘root’@’%’ ;--分配所有权限,privileges 可省略

 如果想让授权的用户,也可以将这些权限 grant 给其他用户,需要增加 grant option

grant all privileges on *.* to ‘root’@’%’  with grant option;

查看权限

show grants for ‘用户名’

4、刷新权限,分配权限后无法立刻生效需要刷新权限

flush privileges

原创粉丝点击