Monday, June 1, 2009

Get MySQL and PHP working on a Mac

I wanted to install a new Wordpress installation on my MacBook and play a little with different language plugins before I'm going to install them in my Wordpress MU on the server.

Apache is default installed on a Mac. Great!
MySQL installation was very easy. Just download and install. I'm using MySQL Administration and it works perfect. Created a user and catalog for wordpress with it.
Then downloaded and unzipped Wordpress in my users directory and tried to run the installation. It didn't work because it couldn't connect to MySQL. It was running however and I was able to connect using the administrator.

Apparently it's caused because MySQL puts its socket file on a different location. The solution was easy:

Open terminal and type the following : 
sudo mkdir /var/mysql 
sudo ln -s /private/tmp/mysql.sock /var/mysql/mysql.sock 
Then, open System Prefs > Sharing and refresh your Web Sharing.

Now Wordpress (and phpMyAdmin) can connect to MySQL and everything works perfectly. I love my Mac :P