I have two servers:

  • server1:
  • server2:

They are both CentOS 6. I installed MySQL on both two servers.

I can ping server2 from server1

$ ping

I can connect MySQL server with host on server2

# (server2)
$ mysql -h -u root -p

But I can't connect server2 from server1:

# (server1)
$ mysql -h -u root -p
ERROR 2003 (HY000): Can't connect to MySQL server on '' (113)

My my.cnf on server2:

# /etc/my.cnf
bind-address =

Off course restart it: service mysqld restart

My iptables on server2:

# /etc/sysconfig/iptables
-A INPUT -p tcp --dport 3306 -j ACCEPT

Off course restart it: service iptables restart

I did this on server2:


When did mysql_secure_installation on server2, I allowed remote root connect.

Everything I think good. But can't connect server2 from remote. Why?

  • Have you verified that it's listening on netstat -an | grep tcp | grep 3306
    – Philᵀᴹ
    Apr 20 '17 at 7:29
  • @Philᵀᴹ Yes. The result: tcp 0 0* LISTEN. Apr 20 '17 at 7:40
  • Have a look in your my.cnf file and comment out if there is a line containing skip-networking. Temporarily stop firewalls on both servers sudo service iptables stop and sudo service ip6tables stop. Once this is done, can you post any error messages you get when trying to connect?
    – thatsaru
    Apr 20 '17 at 14:07
  • @thatsaru In my my.cnf file there isn't a skip-networking setting. Even I stoped the firewall the result was the same. I think the reason is my two virtual machines network setting. Apr 21 '17 at 3:13
  • @foo_bar - didn't realise you had virtual machines. So are these both on your desktop/laptop? Also, which virtual technology are you using VMWare/VirtualBox etc.
    – thatsaru
    Apr 21 '17 at 8:01

Your Answer

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

Browse other questions tagged or ask your own question.