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?

link|improve this question
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
feedback

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

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

5 Answers

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.

link|improve this answer
feedback

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.

link|improve this answer
feedback

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?

link|improve this answer
feedback

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

link|improve this answer
feedback

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.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown