"SQLSTATE [HY000] [2002]没有这样的文件或目录";在Laravel中迁移表时出错 [英] "SQLSTATE[HY000] [2002] No such file or directory" error when migrating table in Laravel
问题描述
当我尝试使用"php artisan migrate"命令在Laravel 5中迁移表时,出现以下错误:
中的"SQLSTATE [HY000] [2002]没有这样的文件或目录". . . /vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:47
我的.env文件包括以下默认设置:
DB_HOST=localhost
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
我的database.php文件将mysql列为默认数据库连接,homestead在homestead.yaml文件中列为数据库,homestead是访问mysql并使用show databases;
命令时列出的表之一./p>
对我可能做错了任何事情的想法吗?
尝试在您的.env
文件中使用127.0.0.1
代替localhost
.它对我有用:)
I am getting the following error when I try to migrate a table in Laravel 5 using the "php artisan migrate" command:
'SQLSTATE[HY000] [2002] No such file or directory' in . . . /vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:47
My .env file includes the default settings as follows:
DB_HOST=localhost
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
My database.php file lists mysql as the default database connection, homestead is listed as the database in my homestead.yaml file, and homestead is one of the tables listed when I access mysql and use the show databases;
command.
Any thoughts about what I might be doing wrong?
try 127.0.0.1
instead of localhost
in your .env
file. It works for me :)
这篇关于"SQLSTATE [HY000] [2002]没有这样的文件或目录";在Laravel中迁移表时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!