mac os 更新後,有些東西會出現error,尤其是server相關的設定檔,都變回出廠時的預設值了。
今天php連到mysql時,出現底下的問題:
The website encountered an unexpected error. Please try again later.
Error messagePDOException: SQLSTATE[HY000] [2002] No such file or directory in lock_may_be_available() xxxxxxxxxxxxxxx.
這問題,主要是pdo這個driver找不到mysql.sock
在 /private/etc/php.ini裡頭有個參數,指定到/tmp/mysql.sock:
pdo_mysql.default_socket=/tmp/mysql.sock
設定好,重新啟動apache即可
(# sudo apachectl restart)
ps:為什麼會在/tmp裡頭,我也不知,只是看到別人這樣設定,而我的/tmp底下也有個mysql.sock,試一下就成功了
0 意見:
張貼留言