“没有这样的文件或目录"或“没有这样的宿主是已知的"运行迁移时 [英] "No such file or directory" or "No such host is known" when running migrations
问题描述
我从名为 laravel
的 Laravel 5.4 数据库中删除了 migrations
表.当我运行 php artisan migrate:install
时,出现此错误:
I deleted the migrations
table from a Laravel 5.4 database named laravel
. When I run php artisan migrate:install
, I get this error:
[Illuminate\Database\QueryException]
SQLSTATE[HY000] [2002] No such file or directory
(SQL: select * from information_schema.tables where table_schema = laravel
and table_name = migrations)
我删除并重新创建了数据库.我还运行了 composer update
.没运气.我可以在 phpMyAdmin 中运行命令并手动创建表.
I deleted and recreated the database. I also ran composer update
. No luck. I can run the command in phpMyAdmin and create the table manually.
这个问题有时也会通过类似的 2002 错误表现出来:
This problem sometimes also manifests itself with similar 2002 errors:
[Illuminate\Database\QueryException]
SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: No such host is known.
(SQL: select * from information_schema.tables where table_schema = laravel
and table_name = migrations and table_type = 'BASE TABLE')
[Illuminate\Database\QueryException]
SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known
(SQL: select * from information_schema.tables where table_schema = laravel
and table_name = migrations and table_type = 'BASE TABLE')
推荐答案
如果您使用 localhost
作为 .env
中的 DATABASE_HOST
文件,将其更改为127.0.0.1
,然后运行php artisan config:clear
,然后再次尝试
If you are using localhost
as your DATABASE_HOST
in the .env
file, change it to 127.0.0.1
, then run php artisan config:clear
and now try php artisan migrate:install
again.
这篇关于“没有这样的文件或目录"或“没有这样的宿主是已知的"运行迁移时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!