0

I am running an ubuntu server, which has a LAMP stack. The problem is I can't access MySQL remotely.

I have uncommented the bind-address, in the my.cnf file, but this has no effect.

netstat -tap | grep mysql output is:

tcp        0      0 *:mysql                 *:*                     LISTEN      18079/mysqld    
tcp        0      0 localhost:mysql         localhost:45288         TIME_WAIT   -               
tcp        0      0 localhost:mysql         localhost:45802         ESTABLISHED 18079/mysqld    
tcp        0      0 localhost:mysql         localhost:45286         TIME_WAIT   -               
tcp        0      0 localhost:45802         localhost:mysql         ESTABLISHED 18134/sshd: root
tcp        0      0 localhost:45287         localhost:mysql         TIME_WAIT   -   

I can't telnet the server on port 3306 either, although I have made sure that port 3306 is open, using this command:

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

Telnet output is:

Operation timed out
telnet: Unable to connect to remote host

Result of iptables -L -nv:

 pkts bytes target     prot opt in     out     source               destination         
    0     0 ACCEPT     tcp  --  eth0   *       0.0.0.0/0            0.0.0.0/0           tcp dpt:3306 
    0     0 ACCEPT     tcp  --  eth0   *       0.0.0.0/0            0.0.0.0/0           tcp dpt:3306 
Kao
  • 197
  • 13
  • You need to provide the complete list of your firewall rules. You may have another rule that is prohibiting access to mysql. – Khaled Aug 01 '12 at 08:04
  • That `iptables` command is not a guarantee that port 3306 is now open. Could you add the output of `iptables -L -nv`? – Ladadadada Aug 01 '12 at 08:05
  • fire up your favorite sniffer (e.g. tcpdump). Do you see incoming port 3306 traffic? – Zoredache Aug 01 '12 at 08:07
  • Added iptables -L -nv data to original question – Kao Aug 01 '12 at 08:09
  • Have you the same result if you try your telnet command (with your public IP) from your server which hosts your mysql ? Are you sure about your network interface name (for the iptables command)? – Guillaume USE Aug 01 '12 at 08:06
  • The database runs locally, and it works fine for production, but we have a test database, which we can't access remotely. – Kao Aug 01 '12 at 08:11
  • Check also: [MySQL: Allow both remote AND local connections](http://serverfault.com/questions/171655/mysql-allow-both-remote-and-local-connections). – kenorb Aug 11 '14 at 11:57

1 Answers1

1

The output from iptables shows that it has never seen any traffic on port 3306. (at least since the last flush of the counters).

Something else is blocking that port before it reaches your box. Call your hosting provider.

Ladadadada
  • 25,847
  • 7
  • 57
  • 90
  • I'd check to see if you can connect via the address configured on eth0 first - if not that would confirm it was being blocked elsewhere. – symcbean Aug 01 '12 at 08:31
  • Tried to tcpdump -i eth0 port 3306, no traffic coming. I guess this confirms that it was blocked somewhere else. I'm currently waiting for a VMWare restart, which opens port 3306, I'll accept when I confirm it works. – Kao Aug 01 '12 at 08:41