Friday, June 04, 2010

Can’t connect to MySQL server on ’server’

Its been a long time since I wrote anything here. So, I thought let me resume by sharing a little piece of information I gathered the other day. So, I have been using MySQL to manage some data related to my research. I have installations on multiple machines that I use, and recently I had to install it on another ubuntu machine. I did the following:

<code>sudo apt-get install php5 mysql-server apache2 phpmyadmin</code>

It worked fine, but then, my python script that runs on another machine began to complain that it could not connect to my MySQL server:

 Can't connect to MySQL server on 'server'

Now that was just ridiculous because this has never happened before. So I trolled and trolled till I found what I was looking for:

http://www.webmasterworld.com/forum10/6141.htm

So, turns out that there is this tiny piece of configuration information in your /etc/mysql/my.cnf file that says:

bind-address = 127.0.0.1

which essentially means that all connections coming in from anywhere other than the local machine will not be entertained. Remove or comment that line and restart your server. Things start working!

No comments: