@boblet

lest I forget (Oli Studholme)

Troubleshooting MySQL installation on Snow Leopard

I installed MySQL 5.1.39 via Hivelogic’s “Compiling MySQL on Snow Leopard” and got the dreaded

$ mysql
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)

I eventually tracked the problem down, but MySQL doesn’t make things easy. This error can be from a bunch of things, so here’s what helped

  • Check Console.app—this was showing MySQL trying to start (and failing) every 10 seconds (ouch), but it gave me a pointer to the MySQL log file:
    10/27/09 10:51:24 PM	com.mysql.mysqld[5198]	091027 22:51:24 mysqld_safe Logging to '/usr/local/mysql/var/My_HD.local.err'.
  • Check the MySQL error log—unfortunately this is inside a chowned folder so I needed to sudo tail -n100 /usr/local/mysql/var/My_HD.local.err
  • Check your my.cnf—the log pointed to an error in my /etc/my.cnf file. I should have tried checking or removing the text I added earlier

After fixing the typo, I needed to make a link from the actual mysql.sock file (in /private/var/mysql/mysql.sock) to where mysql expects it (which is actually /private/tmp/mysql.sock, as /tmp and /var actually map to /private/tmp and /private/var respectively):

$ ln -s /private/var/mysql/mysql.sock /private/tmp/mysql.sock