“没有这样的文件或目录";或“未知此类主机"运行迁移时 [英] "No such file or directory" or "No such host is known" when running migrations

查看:134
本文介绍了“没有这样的文件或目录";或“未知此类主机"运行迁移时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从名为 laravel 的Laravel 5.4数据库中删除了 migrations 表.当我运行 php artisan migration: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 ,然后再次尝试 php artisan migration:install .

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆