MySQL 远程访问
1. 修改mysqld监听地址bind-address
修改/etc/mysql/mysql.conf.d/mysqld.cnf即可:
sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf
[mysqld]
bind-address = 0.0.0.0
2. 修改mysql.user表中user:root的host字段为%
外部主机不允许连接到该MySQL服务器的原因:
mysql> USE mysql;
mysql> SELECT user,host FROM user;
+------------------+-----------+
| user | host |
+------------------+-----------+
| debian-sys-maint | localhost |
| mysql.session | localhost |
| mysql.sys | localhost |
| root | localhost |
+------------------+-----------+
4 rows in set (0.00 sec)
直接修改即可:
USE mysql;
UPDATE user SET host='%' WHERE user='root';
FLUSH PRIVILEGES;