无法连接到错误为61的远程MySQL服务器 [英] Can't connect to remote MySQL server with error 61

查看:80
本文介绍了无法连接到错误为61的远程MySQL服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试使用命令行mysql -h <remote-ip> -u any_existing_users -p或任何其他mysql客户端(例如phpmyadmin)连接远程MySQL服务器时,它不起作用,并且错误提示是

When I tried to connect the remote MySQL server by using command line mysql -h <remote-ip> -u any_existing_users -p or any other mysql client such as phpmyadmin, it didn't work and the error hint was

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

但是,当我尝试ssh <remote-ip>并通过mysql -u root -p在本地连接MySQL时,没有问题.

But, when I tried ssh <remote-ip> and connected the MySQL locally by mysql -u root -p, there is no problem.

这是用户表(SELECT User, Host FROM mysql.user;)的一部分:

Here is part of the user table(SELECT User, Host FROM mysql.user;):

+------------------+----------------+
| User             | Host           |
+------------------+----------------+
| root             | %              |
| other_users      | <remote-ip>    |
| root             | localhost      |
+------------------+----------------+

这是iptable:

Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination         
1    RH-Firewall-1-INPUT  all  --  0.0.0.0/0            0.0.0.0/0           

Chain FORWARD (policy ACCEPT)
num  target     prot opt source               destination         
1    RH-Firewall-1-INPUT  all  --  0.0.0.0/0            0.0.0.0/0           

Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination         

Chain RH-Firewall-1-INPUT (2 references)
num  target     prot opt source               destination         
1    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           
2    ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0           icmp type 255 
3    ACCEPT     esp  --  0.0.0.0/0            0.0.0.0/0           
4    ACCEPT     ah   --  0.0.0.0/0            0.0.0.0/0           
5    ACCEPT     udp  --  0.0.0.0/0            224.0.0.251         udp dpt:5353 
6    ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0           udp dpt:631 
7    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:631 
8    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED 
9    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22 
10   REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited 
11   ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:3306 

那有什么问题?

推荐答案

检查您的mysql服务器是否正在使用netstat监听套接字:

Check if your mysql server is listening on a socket with netstat:

netstat -tulpen

并搜索3306.

如果不是或仅在本地主机上,请检查my.cnf并搜索bind-address行并将其更改为:

If not or if only on localhost, check my.cnf and search the bind-address line and change it to:

bind-address = 0.0.0.0

然后重新启动服务器,然后重试.

then restart the server and try again.

这篇关于无法连接到错误为61的远程MySQL服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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