php - 无法在 Laravel 8 中运行迁移:SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known
问题描述
我不明白为什么我的迁移在全新安装 Laravel 8 时失败。这就是我得到的:
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 = bunny and table_name = migrations and table_type = 'BASE TABLE')
at vendor/laravel/framework/src/Illuminate/Database/Connection.php:678
674▕ // If an exception occurs when attempting to run a query, we'll format the error
675▕ // message to include the bindings with SQL, which will make this exception a
676▕ // lot more helpful to the developer instead of just the database's errors.
677▕ catch (Exception $e) {
➜ 678▕ throw new QueryException(
679▕ $query, $this->prepareBindings($bindings), $e
680▕ );
681▕ }
682▕
+33 vendor frames
34 artisan:37
Illuminate\Foundation\Console\Kernel::handle()
我正在使用具有完美 Laravel 环境的 Kali linux,但版本 8 无法正常工作。
解决方案
只需在 .env 文件中将 DB_HOST 的值更改为 127.0.0.1
“改成DB_HOST=mysql
”DB_HOST=127.0.0.1
推荐阅读
- javascript - 如何修复参考错误
- c - 为什么二维数组在将其中一行复制到以前未定义的位置时会发生变化?
- java - 如何解决“java.lang.NumberFormatException:null”
- azure - Azure Devops : ##[error]Error: No package found with specified pattern: d:\a\r1\a\**\*.zip
- javascript - 检查切换是可见还是隐藏,如果隐藏则删除类
- c - 验证日期到当前时间
- java - Opengl - 极端的纹理质量损失
- javascript - 如何在订阅范围之外显示数据/如何使用回调
- python - TypeError:“NoneType”类型的对象在 beautifulsoup 和 selenium Python 中没有 len()
- c++ - 我可以重载插入运算符以获取模板化 STL 容器吗?