My php is compiled with the following configuration on CentOS5.5:
./configure --with-mysql=mysqlnd --with-mysqli=mysqlnd ...
When I try to connecting to MySQL, the following error occurred.
Warning: mysql_connect():  No such file or directory (trying to connect via unix:///tmp/mysql.sock) in Command line code on line 1
Find out the exact location of mysql.sock, then set the exact path in php.ini as:
mysqli.default_socket=/path/to/mysql.sock mysql.default_socket=/path/to/mysql.sock pdo_mysql.default_socket=/path/to/mysql.sock
In my situation, the mysql.sock is located at /var/lib/mysql.