尝试连接到远程MySQL主机(错误2003) [英] Trying to connect to remote MySQL host (error 2003)

查看:982
本文介绍了尝试连接到远程MySQL主机(错误2003)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在Debian服务器上运行的MySQL实例,我可以在本地连接到它,没有任何问题。但是,我无法远程连接。当我从我的命令行尝试这一点,我得到以下错误:

 错误2003(HY000):无法连接到MySQL服务器在'< server-ip>'(110)

我已经将用户添加到mysql作为'user'@'*'和'user'@'localhost'。此服务器中的跳过网络设置为false,并将绑定地址注释到my.cnf中。我也尝试使用以下命令在iptables中打开3306端口:

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

以下是我所有iptable防火墙的列表规则,我使用iptables -L进行撤销:

 链INPUT(policy DROP)
target prot opt source destination
ACCEPT全部任何地方
REJECT tcp - 任何地方任何地方tcp dpt:auth reject-with icmp-port-unreachable
ACCEPT icmp - 任何地方任何地方icmp类型8代码0状态新的,相关的,ESTABLISHED,UNTRACKED
接受任何地方的任何地方相关,ESTABLISHED
ACCEPT tcp - 任何地方任何地方tcp spts:1024:65535 dpt:ftp状态新
ACCEPT tcp - 任何地方任何地方tcp s pts:1024:65535 dpt:ssh状态新
ACCEPT tcp - 任何地方任何地方tcp spts:1024:65535 dpt:www state NEW
ACCEPT tcp - < my-server>任何地方tcp spts:1024:65535 dpt:mysql状态新
ACCEPT tcp - 任何地方任何地方tcp dpts:49152:65534状态新
ACCEPT tcp - 任何地方任何地方tcp dpt:mysql
LOG全部 - 任何地方任何地方:avg 5 / min突发5 LOG级别调试前缀`iptables denied:'
ACCEPT tcp - 任何地方任何地方tcp dpt:mysql
LOG tcp - 任何地方任何地方tcp dpt:mysql LOG级别调试

链条FORWARD(policy ACCEPT)
target prot opt source destination

链式OUTPUT(policy ACCEPT)
target prot opt source destination $ b有没有人有任何想法我应该从哪里走?

解决方案

根据您的回应,您需要找到是否存在阻止您的c的服务器之间的设备连接。您还应确保在登录到服务器时您可以在该服务器的以太网地址上远程登录到3306 ...如果不是,您可能没有在 my.cnf ...请参阅 bind-address 参数。


I have a MySQL instance running on a Debian server and I can connect to it locally with no problems. However, I am unable to connect to it remotely. When I try this from my command line I get the following error:

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

I've added the user to mysql as 'user'@'*' and 'user'@'localhost'. skip-networking in this server is set to false and the bind-address is commented out in my.cnf. I've also attempted to open port 3306 in iptables using the following command:

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

Here is a listing of all my iptable firewall rules, which I retreived using iptables -L:

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

Does anyone have any idea where I should go from here?

解决方案

Based on your response, you need to find if there is a device between you and the server that blocks your connection. You should also ensure that you can telnet to 3306 on that server's ethernet address when logged into the server... if not, you probably have not got the service bound to the ethernet in my.cnf... see the bind-address parameter.

这篇关于尝试连接到远程MySQL主机(错误2003)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆