【问题标题】:php artisan migrate throws received invalid response to SSL negotiationphp artisan migrate throws 收到对 SSL 协商的无效响应
【发布时间】:2020-08-07 13:47:15
【问题描述】:

我在 nginx 上有一个带有 postresql 的 laravel 应用

php artisan migrate 

抛出错误:

In Connection.php line 671:
                                                                                                                                               
  SQLSTATE[08006] [7] received invalid response to SSL negotiation: b (SQL: select * from information_schema.tables where table_schema = publ  
  ic and table_name = migrations and table_type = 'BASE TABLE')                                                                                
                                                                                                                                               

In Connector.php line 70:
                                                                       
  SQLSTATE[08006] [7] received invalid response to SSL negotiation: b 


                                                                   

文件:

.env

...

DB_CONNECTION=pgsql
DB_HOST=localhost
DB_PORT=5432
DB_DATABASE=secretdbname
DB_USERNAME=secretusername
DB_PASSWORD=secretpassword 

...

postresql.conf ...

port = 5432 

...

在 php.ini 中启用:

pgsql
pdo_pgsql
mbstring

php -m

...

mbstring
openssl
PDO
pdo_mysql
pdo_pgsql
pgsql

...

存在相应的数据库,用户存在并获得所有权限。 Postgres 服务处于活动状态。 数据库和应用程序位于同一台服务器上。

我尝试过的:

  • 在 .env 和 postgres.conf 中设置不同的端口
  • 使用不同的数据库、用户和密码进行测试
  • 重新启动 postresql
  • 在修补程序 DB::connection()->getPdo();抛出同样的错误
  • 在 DB_HOST 中尝试了 127.0.0.1。而不是本地主机
  • 在 config/database.php 我尝试将 'sslmode' 设置为 'disable'

我有 certbot 的 SSL 证书。

我将不胜感激有关如何解决上述错误的提示。

【问题讨论】:

  • 请尝试php artisan config:cache,然后再次运行。在 tinker 中,测试一些配置值,例如 env("DB_HOST")env("DB_PORT")

标签: laravel postgresql ssl migrate


【解决方案1】:

确实,跟着亚历克斯跑

php artisan config:cache 

帮助,因为它引发了一个稍微不同的错误,这让我找到了实际的解决方案

解决方案:

postgresql.conf 文件有这一行:

listen_addresses = 'localhost'

默认注释,因此解决方案就是取消注释(正如我在原帖中提到的,数据库和应用程序都在同一台服务器上)。

希望它能为将来节省某人的时间。

【讨论】:

    猜你喜欢
    • 2015-04-03
    • 1970-01-01
    • 2018-12-05
    • 2018-08-23
    • 1970-01-01
    • 2016-09-07
    • 2015-04-12
    • 2016-08-09
    • 2020-05-01
    相关资源
    最近更新 更多