06
Jul
Learn how to fix Mac OSX 10.8 PHP, mysql.sock not found issue
After installing MySQL and Apache/PHP, the database connections didn’t work from PHP. They worked only if connect using the MySQL client. Must be a problem with the PHP side.
There is a sock file that PHP was trying to use, and it was in /var/mysql/mysql.sock and loged that the file was not there.
Warning Error: PDO::__construct(): [2002] No such file or directory (trying to connect via unix:///var/mysql/mysql.sock) in [/filename.php, line number]
File or folder were not there. So made a folder and created a symlink to the one that was there, in /tmp/mysql.sock
sudo mkdir /var/mysql sudo ln -d /tmp/mysql.sock /var/mysql/mysql.sock
Just restart Apache and MySQL and now the issue will be fixed.