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:

  1. Thx, saved me a lot of trouble

    ReplyDelete
  2. Great, Great TIP

    THANKS !!!!

    ReplyDelete
  3. You are welcome. Glad it helps!

    ReplyDelete
  4. You saved a lot of my time.

    You got a big bundle of thanks!

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

    ReplyDelete
  6. Excellent! Thanks for this handy nugget of help!

    ReplyDelete
  7. This fixed my issue, thanks!

    ReplyDelete