Error
The website encountered an unexpected error. Please try again later.
I encountered the [PDOException] SQLSTATE[HY000] [2002] No such file or directory
error for a different reason. I had just finished building a brand new LAMP stack on Ubuntu 12.04 with Apache 2.4.7, PHP v5.5.10 and MySQL 5.6.16. I moved my sites back over and fired them up. But, I couldn't load my Laravel 4.2.x based site because of the [PDOException]
above. So, I checked php -i | grep pdo
and noticed this line:
pdo_mysql.default_socket => /tmp/mysql.sock => /tmp/mysql.sock
But, in my /etc/my.cnf the sock file is actually in /var/run/mysqld/mysqld.sock
.
So, I opened up my php.ini and set the value for pdo_mysql.default_socket
:
pdo_mysql.default_socket=/var/run/mysqld/mysqld.sock
Then, I restarted apache and checked php -i | grep pdo
:
pdo_mysql.default_socket => /var/run/mysqld/mysqld.sock => /var/run/mysqld/mysqld.sock
That fixed it for me.
以上是网上的方面修改PHP.ini的参数即可,但我查看我的配置,已是正确的路径,还是出错,继续看Mysql是否能正常登录,发现报以下错误:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
根据提示使用以下方法重启了Mysql:
/etc/init.d/mysqld start
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.15-log MySQL Community Server (GPL)
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
数据库正常登录,网站还没有恢复正常,继续看问题,网站显示:
504 Gateway Time-out
修改了php-fmp的数值,数据一样呀,无解。