Cake is Unable to Connect to Database on Snow Leopard – MySQL

Playing around with CakePHP today.  Ran into a problem where I know – absolutely – that my database.php was correct in Cake.  However, I kept getting this error:

Cake is NOT able to connect to the database.

Keep in mind, I’m using the Apache out of the box with Snow Leopard.

The fix was easy, but man, what a pain!

So I’m writing this to help anyone else that finds this problem…

1. Goto /private/etc/php.ini  (use TextWrangler or vi)
2. Search for ‘mysql.default_socket’ – should be under the [MySQL] section.  For me it was line 1227
3. Modify to look like the following:

;mysql.default_socket = /var/mysql/mysql.sock         <== this is what it was
mysql.default_socket = /private/tmp/mysql.sock
Save it – and restart Apache.
Good luck!