MySQL用户权限操作 [数据库教程]

database

查看当前用户:

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‘;

MySQL用户权限操作

以上是 MySQL用户权限操作 [数据库教程] 的全部内容, 来源链接: utcz.com/z/535019.html

回到顶部