SQLSTATE[HY000][2002]php_network_getaddresses:getaddrinfo失败:未知此类主机。(Laravel 8迁移错误)
安装livewire fresh的新laravel8 jetstream之后 当我运行命令php artisan migrate时 然后它给出了我终端上的错误SQLSTATE[HY000][2002]php_network_getaddresses:getaddrinfo失败:未知此类主机。(Laravel 8迁移错误),php,mysql,laravel,jetstream,Php,Mysql,Laravel,Jetstream,安装livewire fresh的新laravel8 jetstream之后 当我运行命令php artisan migrate时 然后它给出了我终端上的错误 SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: No such host is known. (SQL: select * from information_schema.tables where table_schema = lweb and
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>
问题解决
只需删除DB_HOST=mysql
到
问题解决
只需删除DB_HOST=mysql
到
检查.env文件和config/database.php中的DB_HOST条目,对于您正在使用的数据库,这两个位置的值都应该是127.0.0.1,如果数据库服务器也在与Web服务器相同的机器上运行,那么您还没有启动apache和mysql yetPDO::_constructmysql:HOST=mysql;端口=3306;错误中的dbname=lweb,root,[]显示.env文件中有DB_HOST=mysql,无法解析为主机地址-主机表示托管数据库的服务器的ip地址检查.env文件中的DB_HOST条目和正在使用的数据库的config/database.php,如果数据库服务器也与Web服务器运行在同一台机器上,则该值应为127.0.0.1。您尚未启动apache和mysql yetPDO::\uu\u constructmysql:host=mysql;端口=3306;错误中的dbname=lweb,root,[]显示.env文件中有DB_HOST=mysql,无法解析为主机地址-主机表示承载数据库的服务器的ip地址
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=