Ubuntu16 远程连接MySQL

1、进入MySQL配置目录允许其他IP可以链接

vi /etc/mysql/mysql.conf.d/mysqld.cnf

吧下面这行注释掉

#bind-address           = 127.0.0.1

2、远程连接还是失败,查看日志发现会把访问IP去查找域名,关闭DNS解析

#vi /etc/mysql/my.cnf

加上这个

skip-name-resolve

3、链接仍然失败,查看日志发现关闭DNS解析后找不到自己域名

1       100616 21:05:15 [Warning] 'user' entry 'root@hexuweb101' ignored in --skip-name-resolve mode.
2	100616 21:05:15 [Warning] 'user' entry '@hexuweb101' ignored in --skip-name-resolve mode.

  把数据库里面Mysql库里面的user表的主机改成IP

 update user set Host='11。x.x.x where User='mysql.sys';

update user set Host='11.x.x.x' where User='root';

grant all privileges on *.* to 'root'@'%' identified by 'pawword';    flush privileges;

  然后重启下数据库服务器,链接成功

原文地址:https://www.cnblogs.com/pangxiaox/p/7476340.html