在本地用ems客户端远程连接虚拟机上的mysql server,弹出客户端没有权限访问mysql server。使用下面方法进行设置:
mysql> select host,user,password from user;
+-----------+------+-------------------------------------------+
| host | user | password |
+-----------+------+-------------------------------------------+
| localhost | root | *FAAFFE644E901CFAFAEC7562415E5FAEC243B8B2 |
| rac1 | root | *B68123C4CF08AA9400817DF977A72D557BD930CF |
| 127.0.0.1 | root | *B68123C4CF08AA9400817DF977A72D557BD930CF |
| ::1 | root | *B68123C4CF08AA9400817DF977A72D557BD930CF |
+-----------+------+-------------------------------------------+
4 rows in set (0.00 sec)
创建一个要远程连接mysql server的用户并赋予相应权限:
mysql> create user 'root'@'192.168.72.1';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all on *.* to 'root'@'192.168.72.1' identified by 'root123';
Query OK, 0 rows affected (0.00 sec)
mysql> commit;
Query OK, 0 rows affected (0.00 sec)
mysql> select host,user,password from user;
+--------------+------+-------------------------------------------+
| host | user | password |
+--------------+------+-------------------------------------------+
| localhost | root | *FAAFFE644E901CFAFAEC7562415E5FAEC243B8B2 |
| rac1 | root | *B68123C4CF08AA9400817DF977A72D557BD930CF |
| 127.0.0.1 | root | *B68123C4CF08AA9400817DF977A72D557BD930CF |
| ::1 | root | *B68123C4CF08AA9400817DF977A72D557BD930CF |
| 192.168.72.1 | root | *FAAFFE644E901CFAFAEC7562415E5FAEC243B8B2 |
+--------------+------+-------------------------------------------+
5 rows in set (0.01 sec)
然后再进行连接,ok。
将host字段的值改为%就表示在任何客户端机器上能以root用户登录到mysql server,建议在开发时设为%。
mysql> update user set host = '%' where user = 'root';