尝试连接到远程 MySQL 主机(错误 2003)

2024-01-11

我有一个在 Debian 服务器上运行的 MySQL 实例,我可以毫无问题地在本地连接到它。但是,我无法远程连接到它。当我从命令行尝试此操作时,出现以下错误:

ERROR 2003 (HY000): Can't connect to MySQL server on '<server-ip>' (110)

我已将用户添加到 mysql 作为“user”@“*”和“user”@“localhost”。该服务器中的skip-networking设置为false,并且bind-address在my.cnf中被注释掉。我还尝试使用以下命令在 iptables 中打开端口 3306:

/sbin/iptables -A INPUT -i eth0 -p tcp --destination-port 3306 -j ACCEPT

以下是我使用 iptables -L 检索的所有 iptable 防火墙规则的列表:

Chain INPUT (policy DROP)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             anywhere            
REJECT     tcp  --  anywhere             anywhere            tcp dpt:auth reject-with icmp-port-unreachable 
ACCEPT     icmp --  anywhere             anywhere            icmp type 8 code 0 state NEW,RELATED,ESTABLISHED,UNTRACKED 
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED 
ACCEPT     tcp  --  anywhere             anywhere            tcp spts:1024:65535 dpt:ftp state NEW 
ACCEPT     tcp  --  anywhere             anywhere            tcp spts:1024:65535 dpt:ssh state NEW 
ACCEPT     tcp  --  anywhere             anywhere            tcp spts:1024:65535 dpt:www state NEW 
ACCEPT     tcp  --  <my-server>          anywhere            tcp spts:1024:65535 dpt:mysql state NEW 
ACCEPT     tcp  --  anywhere             anywhere            tcp dpts:49152:65534 state NEW 
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:mysql 
LOG        all  --  anywhere             anywhere            limit: avg 5/min burst 5 LOG level debug prefix `iptables denied: ' 
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:mysql 
LOG        tcp  --  anywhere             anywhere            tcp dpt:mysql LOG level debug 

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

有谁知道我应该从这里去哪里?


根据您的回复,您需要查找您和服务器之间是否有设备阻止您的连接。您还应该确保可以远程登录到该服务器的以太网地址上的 3306当登录到服务器时...如果没有,您可能还没有将服务绑定到以太网my.cnf...参见bind-address范围。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

尝试连接到远程 MySQL 主机(错误 2003) 的相关文章

随机推荐