远程连接CentOS7的mysql报错:Can't connect to MySQL server on 'x.x.x.x' (10060)

前提条件:
1.centos和windows的网络是互通的;
2.MySQL赋予了远程连接的所有权限

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'myPassword' WITH GRANT OPTION;
1
问题:
centos7默认是没有iptables的。根据网上的教程, 我禁用了firewalld,安装iptables,并在iptables中开放了3306端口,可是远程连接一直出错,报错10060.

解决:
关闭iptables,开启firewalld,并在firewalld中开放3306端口。
1.关闭iptables:systemctl stop iptables
2.启动防火墙:systemctl start firewalld
3.设置开机启用防火墙:systemctl enable firewalld.service
4.查看开放的端口:firewall-cmd --list-ports

5.开启防火墙端口:firewall-cmd --zone=public --add-port=3306/tcp --permanent

6.重新加载配置:firewall-cmd --reload

7.查看开放的端口:firewall-cmd --list-ports

最后,连接成功!

posted @ 2019-06-27 17:57  死神敲键  阅读(208)  评论(0编辑  收藏  举报