You are here: Can't connect to local MySQL server through socket '/tmp/mysql.sock' PDO exception « PHP Programming Language « IT news, forums, messages
Can't connect to local MySQL server through socket '/tmp/mysql.sock' PDO exception

Posted by Michal Stankoviansky on 08/29/06 17:40

Hi

Environment: some version of Slackware, Apache 2.2.x, PHP 5.1.5, MySQL
5.0.24.

The issue: I'm using Zend Framework Zend_Db component (which uses PDO).
We have 2 mysql socket related settings in php.ini:

mysql.default_socket = /var/run/mysql/mysql.sock
mysqli.default_socket = /var/run/mysql/mysql.sock

On MySQL command prompt, query "SHOW VARIABLES LIKE '%socket%';"
returns the variable "socket" with correct (desired) value
"/var/run/mysql/mysql.sock".

But still, the output of phpinfo() contains the following lines in
mysql and mysqli sections, respectively:

MYSQL_SOCKET /tmp/mysql.sock
MYSQLI_SOCKET /tmp/mysql.sock

What's worse though is that PDO seems to be using the wrong
"/tmp/mysql.sock" socket and every once in a while the sites
mysteriously stop working and throw the following exception:

SQLSTATE[HY000] [2002] Can't connect to local MySQL server through
socket '/tmp/mysql.sock' (2)

I need a solution how to force PHP/MySQL/PDO (whatever causes this) to
use the specified socket (and stop throwing exceptions). I know that
there is a "unix_socket" option I can use in PDO connection string, but
since I don't directly use PDO but use Zend_Db instead, this is not
possible. I just need PDO to KNOW. (I don't know if the wrong
MYSQL_SOCKET and MYSQLI_SOCKET lines from phpinfo() affect this in any
way...?)

Thank you very much.

Michal

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация