MySQL用户权限操作

时间:2020-08-02 22:21:01   收藏:0   阅读:127

查看当前用户:

select user,host from user;

或:

 

SELECT DISTINCT CONCAT(‘User: ‘‘‘,user,‘‘‘@‘‘‘,host,‘‘‘;‘) AS query FROM mysql.user;

 

创建用户:(创建一个用户可以从任何主机以密码123456远程访问MySQL)

create user ‘root‘@‘%‘ identified by ‘123456‘;

 

修改用户(修改指定用户可以从指定主机远程访问MySQL):

update user set host=‘%‘ where user=‘root‘;

 

删除用户:

delete from user where user=‘xxx‘ and host=‘xxx‘; // root localhost

用户受权:

grant all privileges on *.* to ‘root‘@‘%‘ identified by ‘123456‘;

 

刷新权限:  (该步不能忘记)

FLUSH PRIVILEGES;

create user ‘root‘@‘%‘ identified by ‘123456‘;
评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!