Ancient Post Alert! This entry was published 14 years ago and contains technical information that may no longer be accurate. Proceed with caution.
While gearing up to get the latest version of Stuntbox out the door I set up a new localhost testing environment on my MacBook. That included fresh installs of MySQL and WordPress (using the already-baked-into-OS-X versions of Apache and PHP). Nothing unusual there.
Apparently it had been a little while since I had actively used the combination though, because somebody went and made some changes while I had my back turned.
Cue Breaking Glass
If you’ve ever set up PHP/MySQL on OS X you know it’s no big deal. Uncomment a couple of lines in Apache’s
http.conf file, then download a fresh MySQL install and follow the relatively straightforward instructions. (You always remember to secure your initial user accounts, right?) If you’re used to this sort of dance the whole thing will take you all of a half hour, if that. So I wasn’t paying too much attention post-install when I started throwing other applications into the mix. Phooey on me for not testing the PHP/MySQL connection first though because WordPress immediately coughed up the following hairball:
Error establishing a database connection. This either means that the username and password information in your wp-config.php file is incorrect or we can’t contact the database server at localhost. This could mean your host’s database server is down.
wp-config.php was fine, and MySQL was very much up and running, so that left the database connection. After some trial and error with Google I came across a tech note on Apple’s support site called “Mac OS X Server 10.4.4: Improvements to Apache/PHP/MySQL”. Turns out that, as of OS X 10.4.4, the default socket location for PHP and MySQL has been moved. Fortunately an easy fix is detailed under the second section of the note. Basically it comes down to editing the socket location in your
php.ini file (or creating one if it doesn’t exist yet).
I find it more than a little odd that I had to dig up a note about the server version of the OS to uncover an explanation from Apple about this. That’s important because, while there are other fixes out there, this is the only that has any hope of explaining why the change was made.
Snow Leopard Update
Since this post was originally written, OS X 10.6 “Snow Leopard” has been released. A modified version of the above instructions now applies.