Can';t在Laravel 8中运行迁移:SQLSTATE[HY000][2002]php_network_getaddresses:getaddrinfo失败:名称或服务未知

Can';t在Laravel 8中运行迁移:SQLSTATE[HY000][2002]php_network_getaddresses:getaddrinfo失败:名称或服务未知,php,mysql,laravel,laravel-8,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 an

我不明白为什么我的迁移在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\u HOST=mysql
更改为
DB\u HOST=127.0.0.1

我也遇到了同样的问题 我安装了两个php环境,第一个是xamp环境,第二个是计算机环境 转到计算机位置。 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 

警告不带分号,请勿添加分号

这表示它无法解析选项(可能是.env文件)中指定的数据库的IP。如果
DB\u HOST
设置正确(并且不会出现两次,值正确或不正确),请检入
.env
文件。您试图调试该问题的原因是什么?请在您的答案中添加一些解释,以便其他人可以从中学习。通常,如果缺少扩展,错误看起来会不同
extension=php_pdo_mysql
extension=php_pdo_mysql.so