0

I have an OpenVPN server installed on a server. What I'm trying to do connect from the OpenVPN server using the mysql client to the MySQL server than is connected to the OpenVPN server using a client. I can ping back and forth between the servers, no issues. However, if I use the MySQL client on the OpenVPN server to try to connect to the MySQL server I get a

ERROR 2003 (HY000): Can't connect to MySQL server on '10.8.0.6' (111)

with 10.8.0.6 being the connected to the OpenVPN server at 10.8.0.1.

I thought it might be IPTables but adding explicit INPUT and OUTPUT one the client and the server didn't change anything. Telnet 10.8.0.6 3306 didn't work either. I have verified that MySQL is running on 3306:

me@db:~# lsof -i4 -P | grep -i mysql
mysqld  6192 mysql   10u  IPv4  40596      0t0  TCP localhost:3306 (LISTEN)

So what am I doing wrong? Google has been less than helpful, as far as what I could find it should just work.

2

Your MySQL server is listening only to localhost (127.0.0.1) so you can't connect to it from other servers. This is a default "safe" setting to prevent other machines from being able to connect to MySQL unless you explicitly allow it.

Edit your my.cnf file (probably in /etc/my.cnf) and change the bind-address from 127.0.0.1 to one of:

  • The IP address of your MySQL server
  • 0.0.0.0 to listen on all IPv4 addresses configured on the server
  • :: to listen on all IPv4 and IPv6 addresses.

http://dev.mysql.com/doc/refman/5.5/en/server-options.html#option_mysqld_bind-address

  • That's it. The address binding was for 127.0.0.1, commented that out, restarted MySQL and it works. Thanks. – Ross R Apr 4 '13 at 12:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.