PDO_MYSQL connect fallback from localhost do /tmp/mysql.sock
| From: | Andreas Korthaus | Date: | Tue, 07 Nov 2006 23:58:12 +0000 |
| Subject: | PDO_MYSQL connect fallback from localhost do /tmp/mysql.sock | ||
| Groups: | php.pecl.dev | ||
| Request: | Send a blank email to pecl-dev+get-4317@lists.php.net to get a copy of this message | ||
Hi!
I have a strange problem when connecting to a MySQL 4.0.24 server using PDO_MYSQL (from PHP 5.1.6).
I tried the following code:
<?php
new PDO('mysql:host=localhost;dbname=test');
?>
And the error is:
SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'
If I change the hostname to the external name:
<?php
new PDO('mysql:host=example.com;dbname=test');
?>
it works.
In my.cnf "socket" is set to /var/run/mysqld/mysqld.sock, not /tmp/mysql.sock.
There is no php.ini loaded, the precompiled mysql library from MySQL AB has been used.
In phpinfo() the setting "MYSQL_SOCKET" from the old mysql extension says /tmp/mysql.sock!
Do you have any idea what is going wrong here?
Should I file a bug report?
best regards
Andreas