php - 无法在 Laravel 8 : SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known 中运行迁移

标签 php mysql laravel laravel-8

我不明白为什么我的迁移在 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

关于php - 无法在 Laravel 8 : SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known 中运行迁移,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65237844/

相关文章:

php - Select on Mysql逆序

Laravel Eloquent 比较列值

postgresql - Eloquent ORM 和 postgres 迁移 - 是否可以分配表达式默认值?

php - 与货币和国家相关的产品的数据库结构

php - 使用php从sql数据库创建json对象

mysql - Symfony 组合 2 个查询

php - 为什么 foreach 循环中的 PHP Mysql 查询总是返回数据库中的第一个结果?

php - WooCommerce - 将元数据添加到 Stripe Payment

PHP 和 MySql 转储文件中的非法排序规则混合

php - SQLITE 按组选择并限制每个组的结果