修改 /etc/mysql/my.cnf 把 bind-address =127.0.0.1 注释掉
然后
1.设置远程访问
将相应用户数据表中的host字段改成'%';
use mysql
mysql> select host, user from user;
+-----------+------+| host | user |+-----------+------+| 127.0.0.1 | root || ::1 | root || localhost | || localhost | root |+-----------+------+4 rows in set (0.00 sec)可以看出没有%这一项
mysql> update user set host='%' where user='root';
ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY'
这里报了一个错误,我们不予理会。
mysql> select host, user from user;
+-----------+------+
| host | user |
+-----------+------+
| % | root |
| 127.0.0.1 | root |
| ::1 | root |
| localhost | |
+-----------+------+
4 rows in set (0.00 sec)
mysql> flush privileges;
看到数据表中已经有这一项了,那么就可以实现远程访问了。