Configure mysql.sock to connect to local mySQL server through socket

Can’t connect to local MySQL server through socket /tmp/mysql.sock

The cause is: The mySQL by default attempts to connect through a local file called a socket instead of connecting to the address ( for localhost. The default location of this socket file, at least on OSX, is /tmp/mysql.sock.

Run this code in the terminal to create symlink to finding the correct socket.

sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sock

After this you will need to reboot your mySQL to take effect.

Hopefully this helps you alot from having a rough morning.

Posted in PHP

Leave a Reply

Your email address will not be published. Required fields are marked *