Broken mysql PHP link with mac OS X update? Here is the solution

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:

  1. 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
  2. Replace all occurrenses of /var/mysql/mysql.sock, with /tmp/mysql.sock in /etc/php.ini, save the file.
  3. 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. 😡

À propos de Stéphane Le Solliec

Développeur web.
Cette entrée a été publiée dans System Administration, avec comme mot(s)-clef(s) , , , , , . Vous pouvez la mettre en favoris avec ce permalien.

Les commentaires sont fermés.