mysql远程授权用户或主机【mysql】

授权操作:

//授权操作
grant all on *.* to 'root'@'%' identified by '123456' with grant option;
//允许账户root从任何主机连接到所有数据库(*.*)
grant all on test.* to 'user'@'%' identified by '123456' with grant option;
//允许账户user从任何主机连接到test数据库(test.*)

释放远程授权:
revoke all on *.* from 'user'@'%';
//禁止用户user从任何主机访问所有数据库
revoke all on test.* from 'user'@'%';
//禁止用户user从任何主机访问test数据库
flush privileges;    //刷新系统授权表

检查用户授权情况

mysql> use mysql;
Database changed
mysql> select host,user from user;
+-----------+------+-------------------------------------------+
| host      | user | password                                  |
+-----------+------+-------------------------------------------+
| localhost | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
+-----------+------+-------------------------------------------+
;