Remote Access MySQL connection error

LearningSlowly picture LearningSlowly · Mar 31, 2015 · Viewed 16.1k times · Source

I am trying to remotely connect to a MySQL server. I have followed advice from (1) and setup a user on the ip address I will be remotely accessing from.

user$ mysql -u TestUser -p -h 129.169.66.149
Enter password:
ERROR 2003 (HY000): Can't connect to MySQL server on '129.169.66.149' (60)

I have checked and the port (default, 3306) is correct and the ip address is correct. MySQL is also running.

From a remote computer, I can successfully ping the server

ping 129.169.66.149
64 bytes from 129.169.66.149: icmp_seq=48 ttl=63 time=1.010 ms

But when I use Telnet:

TELNET 129.169.66.149
Trying 129.169.66.149...
telnet: connect to address 129.169.66.149: Operation timed out
telnet: Unable to connect to remote host

Can anyone advise? Is this a firewall issue?

(1) - https://superuser.com/questions/826896/access-wordpress-mysql-database-remotely

Answer

Vince picture Vince · Mar 31, 2015

First try to check TCP connection issue, using netcat and telnet : on the mysql server, stop mysqld (to release port 3306) and run netcat on listen mode :

nc -l -p 3306

Now, netcat is listening port 3306 (like mysqld does when it's running) and will show what happen on that port (incoming connections, what's in the wire...).

On your remote computer (mysql client), try to connect to the mysql server host :

telnet 129.169.66.149 3306

or :

nc 129.169.66.149 3306

If this is not working, this is not a mysql server configuration issue but a network issue, and you must check your router firewall rules.

Otherwise, your problem comes from mysql server settings. Check your mysql configuration file for bind-address, and remove them to make mysqld accept clients from any IP address.