WordPress “error establishing a database connection” on OS X Leopard

From : http://bustoutsolutions.com/blog/2007/12/13/wordpress-error-establishing-a-database-connection-on-os-x-leopard/

If you are getting this error on your local WordPress installation using Mac OS X Leopard, there is a simple fix. You might be seeing this error even though PHP is working fine, and MySQL is working fine. In order to get WordPress to work create a php.ini file.

sudo cp /private/etc/php.ini.default /private/etc/php.ini
Change permissions and edit the file

sudo chmod 777 /private/etc/php.ini
vi php.ini

Change mysql.default_socket = [blank] to

mysql.default_socket = /private/tmp/mysql.sock

Restart Apache and you should be good to go!