#登陆mysql
$ mysql -uroot -p
mysql> use mysql;
mysql> update user set host = '%' where user = 'root';
mysql> select host, user from user;
+-----------+------------------+
| host | user |
+-----------+------------------+
| % | root |
| localhost | debian-sys-maint |
| localhost | mysql.session |
| localhost | mysql.sys |
+-----------+------------------+
4 rows in set (0.00 sec)
#ok 退出MySQL 重启服务
mysql> quit;
$ service mysql restart
#发现客户端远程还是连接不上 继续修改mysql.cnf配置文件
#需要root权限,配置文件是只读的
$ sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
#往下翻,注释掉这一行,保存退出
# bind-address = 127.0.0.1
#重启服务
$ service mysql restart;
#ok 可以了
https://www.cnblogs.com/wilwei/p/10244774.html