Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't connect to remote MySQL server with error 61

Tags:

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) 

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?

like image 749
Wenhao Ji Avatar asked Apr 23 '13 05:04

Wenhao Ji


People also ask

Can not connect MySQL 61?

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.

Can't connect to remote MySQL server client connected?

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.

Can not connect MySQL server on localhost 3306?

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.


1 Answers

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.

like image 90
Kaffee Avatar answered Sep 23 '22 21:09

Kaffee