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

标签 mysql debian iptables mysql-error-2003

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

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

我已将用户添加到 mysql 作为 'user'@'*' 和 'user'@'localhost'。此服务器中的 skip-networking 设置为 false 并且绑定(bind)地址在 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

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

最佳答案

根据您的回复,您需要确定您与服务器之间是否有设备阻止您的连接。您还应该确保您可以在登录到服务器时在该服务器的以太网地址上 telnet 到 3306...如果不能,您可能没有在 my.xml 中将服务绑定(bind)到以太网。 cnf...见bind-address参数。

关于mysql - 尝试连接到远程 MySQL 主机(错误 2003),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5713808/

相关文章:

ubuntu - Debian 打包 - 处理修改/创建的文件,debian/rules

linux - 无法在 Debian 8 Jesse 上安装 Code::Blocks IDE

java - iptables 阻止我远程登录到端口 80 上的外部服务器

build - 基于条件的包依赖 [debian]

c - 应用程序未收到 iptable 修改的 Netlink 通知

linux - 如何以编程方式即时管理 iptables 规则?

mysql - 在 MySQL 中存储一周的可用日期

mysql - 如果是我,请选择两个选项;如果是其他用户,请仅选择一个选项

php - 如何用php重复进行select查询?

MySQL - 在单个查询中更新列的顺序