Tuesday, August 19, 2008

Can't Connect to MySQL Server: error 10061

I encounter this problem when trying to connect from my development machine to Coniques database server, which is hosted on different machine. I have setup all user permission to make sure that user can connect from remote host.

The database server is running Ubuntu Server Edition using MySQL as the database engine. The development machine is running Windows XP Pro and I utilize MySQL Connector/ODBC 3.51 to connect. I get following error message when trying to connect:
[MySQL][ODBC 3.51 Driver]Can't connect to MySQL server on 'server_name' [10061]
I then try to connect using command line:
mysql -h server_name -u root -p
and get following error:
ERROR 2003 (HY00): Can't connect to MySQL server on 'server_name' (1111)
This must be some kind of stupid configuration error that I do not know about. I spend some time googling around and manage to find the solution:
  1. Edit the configuration file located at /etc/mysql/my.cnf
  2. Find the line bind-address = 127.0.0.1. The default value 127.0.0.1 means that it will only accept connection from local machine. I change the value to 0.0.0.0 and save it
  3. Restart MySQL by issuing /etc/init.d/mysql restart
Now, I can establish connection from the remote machine.

8 comments:

Rafael said...

thanks!

Anonymous said...

Thx, saved me a lot of trouble

Anonymous said...

Great, Great TIP

THANKS !!!!

Christian Losari said...

You are welcome. Glad it helps!

Asif Shahzad said...

You saved a lot of my time.

You got a big bundle of thanks!

Sudeeraka said...

WOOW nice 1 brother you saved my day :-))))
Thank you very much

Jon Gibbins said...

Excellent! Thanks for this handy nugget of help!

Bryan said...

This fixed my issue, thanks!