//jerrywalsh.org

coding, hacking, startups, computer security, technology and more

Solving MySQL ERROR 2013 (HY000)

Recently it became necessary to expose a MySQL instance to some customers across the internet. The MySQL daemon had previously been locked down using the my.cnf skip-networking directive. I removed this the MySQL configuration file and restarted the daemon. Sockstat showed MySQL was now listening but when I attempted to connect from a remote site I received this cryptic error message:

 ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 0

Nothing showed on any logs (system logs or even the MySQL error log) so I was stumped for a little bit. Also, connecting to the mysql server via its socket or localhost worked just fine.  After some painful moments I finally figured out what the problem was - MySQL uses tcp wrappers and so I had to make the appropriate entry in /etc/hosts.allow:

mysqld : ALL : allow

Once added remote connections were instantly accepted and the error message went away - hurray!