Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

When I am trying to connect to a MySQL database from a remote computer I get a prompt saying: Connection Failed: [HY000] [MySQL][ODBC 5.1 Driver]Can't Connect to MySQL server on 'XXX.XXX.XX.XX' (10060)

I have created a user account in the MySQL Administrator and added a host to enable remote access, I have also made an exception for my Windows Firewall on port 3306 but the connection still fails.

What is the problem?

Thanks!

share|improve this question

migrated from stackoverflow.com Apr 30 '10 at 14:23

This question came from our site for professional and enthusiast programmers.

1  
Not a programming related question, but anyway, check if the remote computer is able to connect to any other service running on the same computer you're running the MySQL server. I doubt it is however. Very likely to be a NAT problem. –  jweyrich Apr 30 '10 at 12:51
    
@jweyrich: You were very right, the ISP have blocked all ports but 21, 80 and 3389. –  Anonymous May 1 '10 at 9:12

5 Answers 5

First of all, it's a very bad idea to have a worldwide open port to your database server. Especially if it's on the MySQL default port. You're just inviting people to try to break in to your database.

Have you tried using a port scanning tool like nmap on your from your remote computer to scan the database server? It will tell you if the port is open with nmap -PN -p 3306 XXX.XXX.XX.XX?

share|improve this answer

I suppose your mysql server is running on windows...thus open a prompt DOS windows and digit:

netstat -an

You should find a row like this:

TCP 0.0.0.0:3306 0.0.0.0:0 LISTENING

This tell you that mysql server is running and listening on TCP port 3306.

Another test you can do is to telnet (from another pc) to you mysql server:

telnet ip_mysql_server 3306

This should open a telent session:

Connected to server_name. Escape character is '^]'. 5.0.XX-community-nt-log

share|improve this answer
    
Thanks for this, I tried connection to the server from the remote computer using "telnet ip_mysql_server 3306" but the connection fails. –  Anonymous Apr 30 '10 at 16:02
    
Maybe this seems a stupid question but...is running mysql server? Which is the result of netstat? –  lg. May 3 '10 at 8:44

Check the mysql configuration: /etc/my.cnf

and comment out:

skip-networking

Now it will be listening to TCP/IP ports, however you have usually blocked direct access to MySQL via the firewall anyway, so it shouldn't be a problem. You can now TCP/IP in over SSH as "localhost" to the MySQL server.

EG windows bat file, putty tunnel:

@putty.exe -ssh -pw PassWord -L 3306:localhost:3306 odbcuser@remoteHost
EXIT

If you have XAMPP/MySQL running on your local machine, change the above port to 3307, ie:

3307:localhost:3306
share|improve this answer

To connect MYSQL from remote server

look at http://www.cyberciti.biz/tips/how-do-i-enable-remote-access-to-mysql-database-server.html

But that's not a good idea. If u are going to access the database from another remote server, why dont you place a file inside your site with some security such htpasswd protection or some authentication module...

If u r going to get data of a mysql server to another server, be precise with the requirement...

If its just for data synchronization go for db server concepts...

share|improve this answer

The likely culprit that people often forget is:

mysql> GRANT ALL ON foo.* TO bar@'123.456.789.123' IDENTIFIED BY 'PASSWORD';

This step is needed to be able to connect from the computer 123.456.789.123 More information and a more complete guide can be found at Holicreature's link.

share|improve this answer
    
Permission gives a different error code. –  jweyrich Apr 30 '10 at 13:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.