localhost is not 127.0.0.1
ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communic ation packet', system error: 2
Today I wanted to use a SSH tunnel to connect to mysql running on one of my ubuntu servers in the internet. I used the same putty connection (defining the tunnel) I used all the time but to no avail. I allways got
ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communic ation packet', system error: 2
I made sure that username & password were correct by logging in to mysql remotely on the server. Then after some searching I finally found the solution: the /etc/mysql/my.cnf file had the
bind-address = 127.0.0.1directive in it. After changing my putty configuration from

to
the connection worked again! It was kind of strange though because at some point in the past it was working even with localhost:3306 and I have another ubuntu server that still works without changing localhost to 127.0.0.1 and I don't know of any difference in the servers configuration.