MySQL /防火墙/无法连接到MySQL服务器

我有一个客户端运行一个bind-address=0.0.0.0的MySQL服务器。

这是iptables输出

 root@host:/var/www# iptables -L Chain INPUT (policy ACCEPT) target prot opt source destination ACCEPT all -- anywhere anywhere REJECT all -- anywhere 127.0.0.0/8 reject-with icmp-port-unreachable ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ssh ACCEPT icmp -- anywhere anywhere ACCEPT tcp -- anywhere mysql tcp dpt:mysql LOG all -- anywhere anywhere limit: avg 5/min burst 5 LOG level debug prefix `iptables denied: ' DROP all -- anywhere anywhere Chain FORWARD (policy ACCEPT) target prot opt source destination DROP all -- anywhere anywhere Chain OUTPUT (policy ACCEPT) target prot opt source destination ACCEPT all -- anywhere anywhere 

一个Web服务器可以连接到MySQL服务器,但另一个服务器不能。 他们都使用相同的用户名和密码连接在相同的IP地址上。 看来有另一个防火墙configuration,阻止这个请求。 我不知道还有什么要检查的。

 mysql -h <host> -u <user> -p<password> ERROR 2003 (HY000): Can't connect to MySQL server on '<host>' (110) 

任何想法指向正确的方向?

更新

事实certificate,新的Web服务器设置在不同的数据中心比MySQL服务器,所以内部networkingIP无法沟通。

我认为你的问题是在你的iptables的第二行:

 REJECT all -- anywhere 127.0.0.0/8 reject-with icmp-port-unreachable 

它应该在最后

这一天有这个。 是由恢复数据库,当我恢复我的MySQL数据库(包含我的用户)

不得不手动创build用户来解决我的问题。

你的mysql服务器用户是否有权限接受来自远程服务器的连接。

 create user 'db_user'@'ip.address.of.remote.server' identified by 'password'; GRANT ALL PRIVILEGES ON test.* to 'db_user'@'localhost' identified by 'password'; 

例如,如果你的客户端的IP地址是11.22.33.44

在你的mysql服务器上创build一个testing数据库

 create database test; 

现在创build一个testing用户

 create user 'db_user'@'11.22.33.44' identified by 'password'; 

现在授予权限

 GRANT ALL PRIVILEGES ON test.* to 'db_user'@'11.22.33.44' identified by 'password'; 

testing完成后,请删除testing数据库并testing用户