Attempting to connect to a remote MySQL host (error 2003)

I have a MySQL instance running on a Debian server and I can connect to it locally without any problems. However, I cannot connect to it remotely. When I try this from my command line, I get the following error:

ERROR 2003 (HY000): Can't connect to MySQL server on '<server-ip>' (110) 

I added the user to mysql as 'user' @ '*' and 'user' @ 'localhost'. skip-networking on this server is set to false, and the binding address is commented out in my.cnf. I also tried opening port 3306 in iptables using the following command:

 /sbin/iptables -A INPUT -i eth0 -p tcp --destination-port 3306 -j ACCEPT 

Here is a list of all my iptable firewall rules that I followed with iptables -L:

 Chain INPUT (policy DROP) target prot opt source destination ACCEPT all -- anywhere anywhere REJECT tcp -- anywhere anywhere tcp dpt:auth reject-with icmp-port-unreachable ACCEPT icmp -- anywhere anywhere icmp type 8 code 0 state NEW,RELATED,ESTABLISHED,UNTRACKED ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED ACCEPT tcp -- anywhere anywhere tcp spts:1024:65535 dpt:ftp state NEW ACCEPT tcp -- anywhere anywhere tcp spts:1024:65535 dpt:ssh state NEW ACCEPT tcp -- anywhere anywhere tcp spts:1024:65535 dpt:www state NEW ACCEPT tcp -- <my-server> anywhere tcp spts:1024:65535 dpt:mysql state NEW ACCEPT tcp -- anywhere anywhere tcp dpts:49152:65534 state NEW ACCEPT tcp -- anywhere anywhere tcp dpt:mysql LOG all -- anywhere anywhere limit: avg 5/min burst 5 LOG level debug prefix `iptables denied: ' ACCEPT tcp -- anywhere anywhere tcp dpt:mysql LOG tcp -- anywhere anywhere tcp dpt:mysql LOG level debug Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination 

Does anyone know where to go?

+25
mysql debian mysql-error-2003 iptables
Apr 19 2018-11-11T00:
source share
4 answers

Based on your answer, you need to find if a device exists between you and the server blocking your connection. You also need to make sure that you can telnet up to 3306 at this network address of the server when entering the server ... If not, you probably did not get the ethernet service in my.cnf ... see bind-address parameter .

+12
Apr 19 2018-11-11T00:
source share

You should check your MySQL Server configuration to make sure it is bound to 127.0.0.1, then you can only connect to mysql if your application is on the same server. There is an easy way to set up a website, and you can manage it through a web interface.

+1
Jun 12 '13 at 4:44
source share

This may be due to the closing of port 3306, check the status of your server.

http://www.yougetsignal.com/tools/open-ports/

If it appears closed, it means that you cannot access it from the machine to open the port

ufw - simple firewall

The default firewall configuration tool for Ubuntu is ufw. The following are some examples of using ufw:

First, ufw must be enabled. At the command prompt, type:

 sudo ufw enable 

To open the port (mysql):

 sudo ufw allow 3306 

To see the firewall status, type:

 sudo ufw status 
+1
Feb 24 '17 at 5:40
source share

If you are using a VPN connection to connect to a remote database server and you get this error, just check two simple steps ...

1) In the Windows machine, go to the path "Control Panel \ Network and Internet \ Network Connections" and right-click on the local network and go to the properties. Click on TCP / IPv4 and go to Properties. Make sure the IP and DNS server (if you use DHCP or not?).

2) After that, reboot the machine and check it again.

Hope this works. In my case it works.

Note. Make sure all your settings are correct. This answer is funny, but it works in my case :)

Thank!

0
Jun 21 '17 at 16:06
source share



All Articles