【问题标题】:Password authentication failed error on running laravel migration运行 laravel 迁移时密码验证失败错误
【发布时间】:2017-07-11 22:43:10
【问题描述】:

我正在尝试在 DigitalOcean 液滴上部署我的 Laravel 应用程序。液滴是用 nginx、php7 和 postgres 设置的,我跟进了 DigitalOcean 的 tuts 以了解如何设置它们。然后我尝试关注this tutorial,了解如何使用 git hook 等部署 Laravel 应用。

现在应用程序本身已启动并运行,我可以访问页面和所有内容。但我无法运行php artisan migrate。我一直在更改 .env 文件上的数据库用户名、名称、密码,但我总是得到 exact 相同的错误:

[Illuminate\Database\QueryException]
SQLSTATE[08006] [7] FATAL:  password authentication failed for user "deploy"
FATAL:  password authentication failed for user "deploy" (SQL: select * from information_schema.tables where table_schema = apollo and table_name = migrations)


[Doctrine\DBAL\Driver\PDOException]
SQLSTATE[08006] [7] FATAL:  password authentication failed for user "deploy"
FATAL:  password authentication failed for user "deploy"


[PDOException]
SQLSTATE[08006] [7] FATAL:  password authentication failed for user "deploy"
FATAL:  password authentication failed for user "deploy"

这是我对数据库的最新.env 配置:

DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_USERNAME=postgres
DB_DATABASE=postgres
DB_PASSWORD=[my password]
DB_SCHEMA=public

如您所见,如此荒谬的是,即使将DB_USERNAME 设置为postgres,错误仍然会显示for user "deploy"

我一直在谷歌搜索,最接近的事情,或者我认为是这样,是更新/etc/postgresql/9.5/main/postgresql.conf 上的一些配置,即生成listen_addresses = '*'。我更新了它,重新启动了 postgres 服务,但仍然得到完全相同的错误。

谁能帮我指出我错过了什么?

谢谢。

【问题讨论】:

  • 这里只是一个长镜头。不是解决方案。尝试清除您的配置缓存。 php artisan config:cache.
  • @EddyTheDove 有效!但是现在似乎每次更改配置时都必须清除缓存。有没有更好的解决方案?
  • 您在特定环境中实际配置的频率。无论如何,您可以使用php artisan config:clear 来避免缓存。
  • 你是对的,谢谢伙计!

标签: postgresql laravel laravel-5.3 psql artisan-migrate


【解决方案1】:

这是由于缓存而发生的。

当你运行时,php artisan config:cache,它会缓存配置文件。每当事情发生变化时,您都需要继续运行它以更新缓存文件。但是,如果您从不运行该命令,它将不会缓存。

这对于生产来说是可以的,因为配置不会经常更改。但是在 staging 或 dev 期间,您可以通过清除缓存来禁用缓存,并且不要运行缓存命令

所以,只要运行php artisan config:clear,不要运行之前的命令以避免缓存

【讨论】:

  • 这让我对工匠命令有了更好的理解
猜你喜欢
  • 2020-05-27
  • 2021-10-20
  • 2019-11-18
  • 2016-08-30
  • 2017-10-29
  • 1970-01-01
  • 1970-01-01
  • 2020-10-24
  • 2020-05-10
相关资源
最近更新 更多