【问题标题】:SQLSTATE[08006] timeout expiredSQLSTATE[08006] 超时过期
【发布时间】:2019-03-10 16:44:26
【问题描述】:

我正在尝试使用带有 homestead 和 VirtualBox 的 Vagrand 将 laravel 项目连接到 postgresql 数据库,但是在迁移时我总是在下面收到此错误,我尝试更改主机和端口,但仍然相同。有人可以给我一个线索来解决这个问题吗?我查看了很多具有相同错误的问题,但没有一个有帮助,对不起,如果是简单的或者已经有一个应该解决的问题!

非常感谢!

Illuminate\Database\QueryException  : SQLSTATE[08006] [7] timeout expired (SQL: select * from information_schema.tables where table_schema = public and table_name = migrations)

 at /home/arthur/ERPet/erpet/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664
  660|         // If an exception occurs when attempting to run a query, we'll format the error
  661|         // message to include the bindings with SQL, which will make this exception a
  662|         // lot more helpful to the developer instead of just the database's errors.
  663|         catch (Exception $e) {
> 664|             throw new QueryException(
  665|                 $query, $this->prepareBindings($bindings), $e
  666|             );
  667|         }
  668|

Exception trace:

1   PDOException::("SQLSTATE[08006] [7] timeout expired")
  /home/arthur/ERPet/erpet/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70

2   PDO::__construct("pgsql:host=192.168.10.10;dbname=erpet;port=5432;sslmode=prefer", "homestead", "secret", [])
  /home/arthur/ERPet/erpet/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70

Please use the argument -v to see more details.

【问题讨论】:

  • 主机 192.168.10.10 是 LAN 主机。如果您保留默认配置,大多数数据库将绑定到 127.0.0.1 (localhost),因此不会接受 localhost 之外的连接。检查您的配置并确保您的绑定地址更改为 LAN IP(例如 192.168.10.10)或 0.0.0.0 以允许来自任何地方的连接

标签: laravel vagrant virtualbox homestead


【解决方案1】:

问题是,它没有连接到您的数据库。

我通过将端口从 50861 更改为 5432 解决了这个问题,这是我为 PostgreSQL 提供的默认端口。

【讨论】:

    猜你喜欢
    • 2017-03-24
    • 1970-01-01
    • 2018-10-15
    • 2012-08-11
    • 2020-02-22
    • 2020-07-10
    • 2017-09-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多