Technisches SEO und digitale Strategie

Mac OS X: Trouble with MAMP MySQL


MAMP is for Mac what XAMPP is for windows: A very easy-to-use, but Mac-like web development solution. Everything worked out-of-the box as it should – until I tried to install WordPress on my MacBook. I got a database connection error very early during the WordPress installation process.

So I tried to talk to the mysql server with the mysql command line tool and got this error message: macbook:~ sf$ /Applications/MAMP/Library/bin/mysql -u root -p Enter password: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

This was strange as the mysql server was indeed running; I could verify this by an ps command. Futhermore phpMyAdmin, as provided by MAMP, worked flawlessly. Doing some Google research told me that the problem was connected with the location of mysql.sock.

Running ps -awwx | grep mysql showed, that mysqld had been started by MAMP with the option --socket=/Applications/MAMP/tmp/mysql/mysql.sock, whereas the mysql tool and WordPress assume the socket file here: /tmp/mysql.sock.

With this information the solution is easy: sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sock This creates a symbolic link from the location expected by mysql and wordpress to the location where the socket file resides. Now I can access my mysql server with the mysql command line tool and my local WordPress installation can also talk to the database.