![](/img/trans.png)
[英]Laravel Docker - SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known
[英]Can't run migrations in 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()
我真的嘗試過尋找解決方案,但沒有成功。 我正在使用 Kali linux 和完美的 Laravel 環境,但版本 8 無法正常工作。
只需在.env 文件中將 DB_HOST 的值更改為 127.0.0.1
“將DB_HOST=mysql
更改為DB_HOST=127.0.0.1
”
在這種情況下,需要檢查 .env 文件並將DB_HOST=mysql
更新為DB_HOST=localhost
我在安裝 laravel 后遇到了同樣的問題。
在 .env 文件中將 DB_HOST 的值更改為 127.0.0.1 並不能完全解決我的問題,我還必須使用以下命令重建整個 docker/sail:
sail down -v
和
sail build --no-cache
首先然后在運行之后
sail up -d
我可以運行:
./artisan migrate:fresh
當數據庫憑據發生更改時,需要重新構建。
我遇到了同樣的問題,我安裝了兩個 php 環境,第一個是 xamp 環境,第二個是計算機 go 環境。 “C:\Program Files\php-8.0.3”打開文件“php.ini”並添加不帶;
extension=php_pdo_mysql
extension=php_pdo_mysql.so
第二次點擊xamp配置按鈕更改配置並在文件php.ini中添加這兩行
extension=php_pdo_mysql
extension=php_pdo_mysql.so
沒有分號的警告,不要加分號;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.