Just recently updated Mac OS X (automatic update). Then, I reboot my computer and guess what: PHP is not able to talk to MySQL anymore.
Erreur MySQL [2002] : No such file or directory Can't find /var/mysql/mysql.sock
Here is what you need to tell PHP how to talk to MySQL back again:
- get some php.ini file at /etc/php.ini if you don’t already have one:
I simply copied the /etc/php.ini.default to /etc/php.ini - Replace all occurrenses of /var/mysql/mysql.sock, with /tmp/mysql.sock in /etc/php.ini, save the file.
- Restart Apache (go to system preferences >> Sharing, un-check and re-check « web sharing »).
By doing this, you simply told PHP the correct place to use to communicate with MySQL. Too bad some common Mac OS X update break this.