PDOException SQLSTATE[HY000] [2002] No such file or directory

后端 未结 30 3024
南方客
南方客 2020-11-22 03:23

I believe that I\'ve successfully deployed my (very basic) site to fortrabbit, but as soon as I connect to SSH to run some commands (such as php artisan migrate

30条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-22 03:58

    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.

提交回复
热议问题