查看当前用户:
use mysql;
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;