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)
But, when I tried ssh <remote-ip>
and connected the MySQL locally by mysql -u root -p
, there is no problem.
Here is part of the user table(SELECT User, Host FROM mysql.user;
):
+------------------+----------------+ | User | Host | +------------------+----------------+ | root | % | | other_users | <remote-ip> | | root | localhost | +------------------+----------------+
Here is the 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
So, what's the problem?
Likewise, firewall restrictions on MYSQL port can also be a reason for the MySQL Workbench error 61. The connection will work only when MySQL is running and allow connections from remote IP addresses. Thus, we always check local and external firewalls to make sure they're allowing inbound connection at port 3306.
normally means that there is no MySQL server running on the system or that you are using an incorrect Unix socket file name or TCP/IP port number when trying to connect to the server. You should also check that the TCP/IP port you are using has not been blocked by a firewall or port blocking service.
You can't connect to mysql server on localhost or ip 127.0. 0.1 (3306) because either the mysql server may not be started or it may not be running, or the network connection to the mysql server is not established, or the mysql server port is different.
Check if your mysql server is listening on a socket with netstat:
netstat -tulpen
and search for 3306.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With