2

在我运行命令 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:\xampp\htdocs\liveweb\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▕

  1   C:\xampp\htdocs\liveweb\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70
      PDOException::("PDO::__construct(): php_network_getaddresses: getaddrinfo failed: No such host is known. ")

  2   C:\xampp\htdocs\liveweb\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70
      PDO::__construct("mysql:host=mysql;port=3306;dbname=lweb", "root", "", [])
PS C:\xampp\htdocs\liveweb> 
4

1 回答 1

13

问题解决只需删除 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=
于 2020-12-10T01:19:20.080 回答