Monday, April 15, 2013

Upgrading PHP5 on Mac OS X Server 10.5.8 - Error establishing database connection

I was greeted by the above error message this evening after the long task of installing dependencies and upgrading the installation of PHP5 on my Mac server to get some needed extra features (like the GD library). After the successful installation of the latest PHP5 for Mac OS X 10.5.8 (Leopard) I could no longer access any of the Wordpress sites installed on my server. A closer look revealed the specific error when attempting to load a site was "Can't connect to local MySQL server through socket '/tmp/mysql.sock'"

Evidently the new installation is looking in a different location for mysql.sock (in my case it was in /private/var/mysql/mysql.sock). The fix was relatively simple, create a symlink from where the file exists, to where it is expected to be:

First, find it:

locate mysql | grep sock

Mine:

/private/var/mysql/mysql.sock

Symlink it:

ln -s /the/path/to/mysql.sock /tmp/mysql.sock

Wala, done. What could have been a multi-hour-tear-my-hair-out-and-probably-end-up-rebuilding-the-whole-server issue was resolved quickly and elegantly, without the need of modifying any global parameters in any config files which may break the next time the software is updated, etc.

Now the image processing bits of a Wordpress plugin my wife was wanting for her blog are functional and life is once again good.

No comments:

Post a Comment