我正在尝试在DigitalOcean Droplet上部署我的Laravel应用程序。 Droplet是用nginx,php7和postgres设置的,我跟进了DigitalOcean关于如何设置它们的方法。然后我尝试按照this tutorial关于如何使用git hook等部署Laravel应用程序。
现在应用程序本身已启动并运行,我可以访问所有页面。但我无法运行php artisan migrate
。我一直在更改.env
文件上的数据库用户名,名称和密码,但我总是得到完全相同的错误:
[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服务,但仍然得到完全相同的错误。
任何人都可以帮我指出我错过了什么?
感谢。
答案 0 :(得分:4)
这是由于缓存造成的。
当您运行php artisan config:cache
时,它将缓存配置文件。每当事情发生变化时,您都需要继续运行它来更新缓存文件。但是,如果您从未运行该命令,它将不会缓存。
这适用于生产,因为配置不会经常更改。但是在staging或dev期间,您可以通过清除缓存来禁用缓存,而不是运行缓存命令
因此,只需运行php artisan config:clear
,并且不要先运行命令以避免缓存