Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am trying to connect to mysql server which is installed on my home pc from another pc. I allowed all connection in mysql configuration. There's no firewall blocking on the pc I am trying to connect from. I used the command-

mysql -h Some.Host.IP -u SomeUser -p SomePassword

I am getting-

ERROR 2003 (HY000): Can't connect to MySQL server on 'Some.Host.IP' (10060)

I can connect through php!!

What's the problem? How do I solve it?

share|improve this question

migrated from stackoverflow.com Feb 18 '10 at 0:21

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

    
I assume you have mysqld actually running on the other machine? –  icco Feb 16 '10 at 20:43
    
Yes, it is. I can connect through php which is weird. –  Samuel Martin Feb 16 '10 at 20:46
    
Post your PHP code, to compare with your shell command. Check if you can ping the server. Maybe check if you can connect by telnet to the mysql address+port. –  Pentium10 Feb 16 '10 at 20:50
    
Can't connect through telnet with the port. –  Samuel Martin Feb 16 '10 at 20:55

5 Answers 5

If PHP and MySQL are running on the same server you might want to check if the bind-address option in the MySQL config file (it's probably called my.ini on Windows machines) is actually turned off:

#bind-address = 127.0.0.1

That option can be easily overlooked and needs to be off to allow incoming connections.

share|improve this answer

Is the user you are using allowed in MySQL to connect from the client you are using (or %)? If you are running php on the same server as MySQL, php will connect from localhost, needing only access from localhost but to access with mysql command, you need your machine / user combination to be allowed.

As in other answers, look for #bind-address = 127.0.0.1 in my.cfg or my.ini in windows directory and be sure it is commented or = 0.0.0.0 (for all interfaces) or = your server LAN IP depending on your needs.

share|improve this answer

Is there a firewall at the machine where you are running the mysql server? And if you are trying to connect from outside you local network, you should forward the ports u are using to connect to you mysql server in your router/modem.

share|improve this answer

Do you have firewall exception rule on your server?

And just like mention in previous reply are you connecting on same network or from different network?

share|improve this answer

I think there should be no space after -p option.

-p SomePassword

-pSomePassword

Your syntax should ask for the password and connect to db SomePassword.

Try like this mysql -h Some.Host.IP -u SomeUser -pSomePassword SomeDatabase

share|improve this answer

Your Answer

 
discard

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