The error, which I had been encountering since Day 1, was
“No such file or directory – /tmp/mysql.sock”.I thought it was a compatibility problem with the pre-installed Apache on my Mac. I tried using Xampp and Locomotive -- but the error persisted.
It turns out this is an error unique to Mac OSX. PHP cannot connect to MySQL because it expects the socket file to be in /tmp.
Solution: trick PHP by tweaking the configs of both Mysql (my.cnf) and PHP (php.ini). Full description of solution from the apple.com site is here: http://docs.info.apple.com/article.html?artnum=301457
Here's a brief description of the solution:
Step 1. Create a text file containing the following:
Save the file into /etc/my.cnf. (for Xampp, this is in /Applications/xampp/etc)
Step 2: Then in php.ini make the following change or add the ff entry:
mysql.default_socket = /var/mysql/mysql.sock
Step 3: For good measure, use the xampp control panel to restart xampp (all components)
What stumped me at the start was this. When using the default Xampp config with PHPMyAdmin and MySQL, I encountered no problem. But when i made the changes above, PHPMyAdmin stopped working. This indicated that I needed to make changes to the PHPMyAdmin config file.
I found the solution to the PHPMyAdmin problem by reading through the documentation and is similar to the tweak on PHP config. You just need to tell PHPMyAdmin the location of the mysql.sock file.
Post a Comment
Thank you for commenting! Your comment will be submitted for review and approval. Please return soon!