[PDOException]
SQLSTATE[HY000] [2002] No such file or directory
注意:php -v是5.5,而mysql -v是5.5,这是我的config / database.php的一部分
'mysql' => array( 'driver' => 'mysql', 'host' => 'localhost', 'database' => 'essays', 'username' => 'root', 'password' => 'root', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', ),
我尝试将localhost替换为127.0.0.1无济于事。请帮助。
编辑: 我在php.ini中添加了这三行
mysql.default_socket = /var/run/mysqld/mysqld.sock mysqli.default_socket = /var/run/mysqld/mysqld.sock pdo_mysql.default_socket = /var/run/mysqld/mysqld.sock
我还添加了此符号链接:
sudo mkdir /var/mysql cd /var/mysql && sudo ln -s /Applications/XAMPP/xamppfiles/var/mysql/mysql.sock
但这并没有解决。我也从拉混帐并运行了一个全新的laravel项目到相同的错误后,composer install再php artisan migrate
composer install
php artisan migrate
[PDOException] SQLSTATE[HY000] [2002] No such file or directory
Mac版本是10.7.4
如果使用的是MAMP,请确保将unix_socket键与mysql.sock驻留在MAMP 中的路径的值相加。
unix_socket
mysql.sock
'mysql' => array( 'driver' => 'mysql', 'host' => 'localhost', 'unix_socket' => '/Applications/MAMP/tmp/mysql/mysql.sock', 'database' => 'database', 'username' => 'root', 'password' => 'root', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', ),