• Connecting to: CentOS v?? with MySql 4.?? in Nashville (example public ip=

    Stack: Cable modem as gateway > router with forwarding > CentOs Box

  • Connecting from: Windows 2003 R2 in Dallas (example public ip=

I'm trying to access my MySql server from a remote server through my public IP. When I try to connect, I get an error along the lines of "could not open a connection to the host" after several seconds. It doesn't have the chance to ask me for login credentials. Here are some of the things I've done toward opening this server up for remote connections:

  • Opened port 3306 on my router and forward it to the local IP address of my MySql box.
  • Followed the instructions in this blog entry.
  • Created a user in MySql with access to my desired database (username@ ** Of course, it doesn't even get this far... just thought I'd include this.

When I try to telnet from the box in Dallas to the box in Nashville at port 3306, I get this:

C:\Documents and Settings\Administrator>telnet 3306
Connecting To not open connection to the host, on port 3306: Connect failed

However, I can ping from (sorry for the bad formatting... i tried):

C:\Documents and Settings\Administrator>ping

Pinging with 32 bytes of data:

Reply from bytes=32 time=57ms TTL=54 Reply from bytes=32 time=61ms TTL=54 Reply from bytes=32 time=56ms TTL=54 Reply from bytes=32 time=57ms TTL=54

Ping statistics for Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 56ms, Maximum = 61ms, Average = 57ms

The IP tables for read:

[root@centos ~]# /sbin/iptables -L Chain INPUT (policy ACCEPT) target
prot opt source
RH-Firewall-1-INPUT all -- anywhere anywhere
tcp -- anywhere tcp dpt:mysql

Chain FORWARD (policy ACCEPT) target
prot opt source
RH-Firewall-1-INPUT all -- anywhere anywhere

Chain OUTPUT (policy ACCEPT) target
prot opt source

Chain RH-Firewall-1-INPUT (2 references) target prot opt source destination ACCEPT all -- anywhere anywhere ACCEPT icmp -- anywhere
anywhere icmp any ACCEPT
esp -- anywhere anywhere ACCEPT ah -- anywhere
anywhere ACCEPT udp -- anywhere udp dpt:mdns ACCEPT udp -- anywhere anywhere
udp dpt:ipp ACCEPT tcp -- anywhere anywhere
tcp dpt:ipp ACCEPT all -- anywhere anywhere
tcp -- anywhere anywhere state NEW tcp dpt:mysql ACCEPT
tcp -- anywhere anywhere state NEW tcp dpt:ssh REJECT all -- anywhere anywhere reject-with icmp-host-prohibited

@Sunny: Right now, the local ip address is listed in /etc/my.conf. To see what happened, I replaced the local ip address with When I did that, MySql could not start back up. I guess the bind-address has to be an ip address actually in the box.

I CAN connect to MySql from another machine on the same network using local ip address. However, even with local, I cannot connect using

Any ideas? Not being a linux guy, I'm a little blind.

  • +1 - very well formed question – Sunny Feb 26 '10 at 23:27

Check my.conf and what bindings MySql server has.

It may be so, that it listens only on the local network.

You are looking for bind-address setting in /etc/my.conf or /etc/mysql/my.conf.

If this setting is enabled (usually to bind to only localhost, comment it out, and it will allow MySql to listen on all available interfaces.

In any case, accessing the database server directly over Internet is not a good idea at all.

I would strongly advice you to use ssh tunneling to access the machine over Internet.

On windows, you can use putty to ssh (creating a tunnel) into the MySql machine. You can forward your local 3306 port to the remote one, and then you can access the MySql server using localhost:3306.

  • @Sunny, I updated the question with my response to your answer. Basically, I don't think this will work since the MySql box is not multi-homed. The public IP resides on a router. – Byron Sommardahl Feb 26 '10 at 23:24
  • updated my answer :) – Sunny Feb 26 '10 at 23:27

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.