mysql无法远程连接

在mysql的mysql数据库下:

select user,host from user;(查看,没有本机的访问权限)
grant all privileges on *.* to root@"xxx.xxx.xxx.xxx" identified by "密码";(xx为本机ip,%为所有IP)
flush privileges;
select user,host from user;(添加成功?)

 修改配置文件, 将 bind-address=127.0.0.1 注释掉

文件路径: 

  • /etc/mysql/my.cnf 
  • /etc/mysql/mysql.conf.d/mysqld.cnf (5.7或5.6以上版本)

最后修改系统防火墙, 不要把3306 挡掉就好

原文地址:https://www.cnblogs.com/hujingnb/p/10246208.html