运行laravel迁移时密码身份验证失败错误 [英] Password authentication failed error on running laravel migration

查看:71
本文介绍了运行laravel迁移时密码身份验证失败错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在DigitalOcean Droplet上部署我的Laravel应用.小滴是用nginx,php7和postgres设置的,我跟着DigitalOcean的介绍如何设置它们.然后,我尝试遵循本教程有关如何使用git钩子等来部署Laravel应用的信息.

I am trying to deploy my Laravel app on a DigitalOcean droplet. The droplet is setup with nginx, php7, and postgres, I follow up the tuts from DigitalOcean on how to set them up. Then I try to follow this tutorial on how to deploy the Laravel app using the git hook and so on.

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

Now the app itself is up and running, I can access the pages and all. But I can't run php artisan migrate. I have been changing the database username, name, password on .env file, but I always get the exact same error:

[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 配置:

Here is my latest .env config for the database:

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 ,对于用户"deploy",错误仍然会显示.

As you can see, what is so absurd is that even with the DB_USERNAME is set to postgres, the error will still say for user "deploy".

我一直在搜寻,最接近的东西,或者我认为是,是在/etc/postgresql/9.5/main/postgresql.conf 上更新一些配置,从而使> listen_addresses ='*'.我更新了它,重新启动了postgres服务,但仍然收到完全相同的错误.

I have been googling around and the closest thing, or I thought so, is to update some configuration on /etc/postgresql/9.5/main/postgresql.conf, which is to make listen_addresses = '*'. I updated it, restarted postgres service, and still get the exact same error.

任何人都可以帮助我指出我错过了什么?

Anyone can help me to point out what did I miss?

谢谢.

推荐答案

这是由于缓存而发生的.

This happens due to caching.

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

When you run, php artisan config:cache, it will cache the configuration files. Whenever things get change, you need to keep running it to update the cache files. But, it won't cache if you never run that command.

这对于生产来说是可以的,因为配置不会经常更改.但是在暂存或开发期间,您可以通过清除缓存来禁用缓存,而不必运行cache命令

This is OK for production, since config don't change that often. But during staging or dev, you can just disable caching by clearing the cache and don't run the cache command

因此,只需运行 php artisan config:clear ,并且以前不要运行该命令以避免缓存

So, just run php artisan config:clear, and don't run the command previously to avoid caching

这篇关于运行laravel迁移时密码身份验证失败错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆