Doctrine connection error – symfony 1.4 – php 5.3

Posted November 20th, 2010 in Tehnikalije by Metod

I just got in the sandbox with symfony 1.4 & php 5.3.3. In the beginning everything went well, untill I tried to pull some data from a database. I got this error:

  1. PDO Connection Error: SQLSTATE[HY000] [2002] No such file or directory

Error log said:

  1. PHP Warning:  PDO::__construct() [<a href=‘pdo.–construct’>pdo.–construct</a>]: [2002] No such file or directory (trying to connect via unix:///tmp/mysql.sock)

It made it clear that mysql.sock was missing or I had some configuration problems. Turns out my php.ini file had to be changed a bit.

  1. pdo_mysql.default_socket=/var/run/mysqld/mysqld.sock

Solution?
Find out where mysqld.sock or mysql.sock is residing and change the default value in your php.ini. That should solve the problem.