Zend Debugger Socket link error
錯誤訊息
<b>Fatal error</b>: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/usr/local/zend/mysql/tmp/mysql.sock'
解法一
原本資料庫設定
$dsn = "mysql:host=localhost;dbname=worthmap";
改成
$dsn = "mysql:host=127.0.0.1;port=8889;dbname=worthmap";
解法二
設定檔案超連結 尚未研究成功 懶阿
參考資料
http://www.shanestillwell.com/index.php/2009/11/30/zend-server-mysql-socket-problem-with-pdo-solved/
Zend Server Mysql Socket problem with PDO [Solved]
The Problem
This answer has eluded me for months. I have Zend Server CE installed on my Mac (and linux web servers). I would use a DSN similar to the following (please note that my real password is not ‘root’).
mysql://root:root@localhost/thedatabase
This would result in an error in a PHP Fatal error of
'Can't connect to local MySQL server through socket '/tmp/mysql.sock''
This drove me mad looking for an answer. I had not configured it to connect through a socket, why was it doing that? To add more injury to this insult, if I tried to connect to Zend Server’s mysql socket (/usr/local/zend/mysql/tmp/mysql.sock) I would still get the same error message.
The Best Solution
It’s as simple as specifying 127.0.0.1
in replace of localhost
. I guess if you do this, you force PDO to use a TCP connection.
Solution Alternative
I haven’t tried this, but you could also symlink from
/tmp/mysql.sock
to
/usr/local/zend/mysql/tmp/mysql.sock
.
I’m not a big fan of symlinks that reach outside of the application.
Cause
It seems there is a bug in PDO PHP 5.2.x that is not fixed until 5.3.x.
Resources:
http://forums.zend.com/viewtopic.php?f=44&t=568
留言列表