Mysql – How to resolve “Can’t connect to local MySQL server through socket” error

mac-osxMySQL

I'm trying to install MySQL on OS X.

First I tried MacPorts. I followed the instructions in step 3 of https://trac.macports.org/wiki/howto/MAMP, but when I ran mysqladmin5 or mysql5 I get:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket
'/opt/local/var/run/mysql5/mysqld.sock' (61)

The file mysqld.sock existed.

Then I tried installing using a .dmg from mysql.com. (I ran port uninstall mysql5-server first.) Now, I get:

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

How can I fix this? I see that a lot of questions deal with this, but I haven't found a solution that works for me.

Best Answer

I suspect that you haven't started MySQL server:

ps -ax | grep mysql