SQLSTATE[HY000][2002]php_network_getaddresses:getaddrinfofailed:没有这样的主机是已知的。(Laravel8迁移错误)

当我运行命令 php artisan migrate 时,在新安装了 livewire 的新 laravel8 jetstream 之后,它在我的终端上给出了错误

  SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: No such host is known.  (SQL: select * from information_schema.tables where table_schema = lweb and table_name = migrations and table_type = 'BASE TABLE')

  at C:xampphtdocslivewebvendorlaravelframeworksrcIlluminateDatabaseConnection.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?

  1   C:xampphtdocslivewebvendorlaravelframeworksrcIlluminateDatabaseConnectorsConnector.php:70
      PDOException::("PDO::__construct(): php_network_getaddresses: getaddrinfo failed: No such host is known. ")

  2   C:xampphtdocslivewebvendorlaravelframeworksrcIlluminateDatabaseConnectorsConnector.php:70
      PDO::__construct("mysql:host=mysql;port=3306;dbname=lweb", "root", "", [])
PS C:xampphtdocsliveweb> 

回答

问题解决只需删除 DB_HOST=mysql

DB_CONNECTION=mysql
DB_HOST=localhost
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=lweb
DB_USERNAME=root
DB_PASSWORD=
  

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=lweb
DB_USERNAME=root
DB_PASSWORD=


以上是SQLSTATE[HY000][2002]php_network_getaddresses:getaddrinfofailed:没有这样的主机是已知的。(Laravel8迁移错误)的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>