我已经安装了PostgreSQL 8.4, Postgres客户端和Pgadmin 3。控制台客户端和Pgadmin用户“postgres”身份验证失败。我已经输入用户作为“postgres”和密码“postgres”,因为它以前工作过。但是现在身份验证失败。我以前做过几次都没有这个问题。我该怎么办?发生了什么?

psql -U postgres -h localhost -W
Password for user postgres: 
psql: FATAL:  password authentication failed for user "postgres"
FATAL:  password authentication failed for user "postgres"

当前回答

在登录postgres时,我也遇到了这个问题。我遵循以下步骤,并能够登录postgres和pgadmin。

步骤1:使用终端打开Postgres。

sudo su postgres

步骤2:打开psql。

psql

步骤3:重置用户密码

ALTER USER user_name WITH PASSWORD 'new_password';

Step4:赋予用户对数据库的权限。

GRANT ALL PRIVILEGES ON DATABASE my_database TO db_user;

其他回答

时间过得真快啊!

在版本12中,我必须在这里使用“password”而不是“ident”:

local   all             postgres                                password

不使用-h选项进行连接。

以下是我尝试登录的一些组合:

# login via user foo
psql -Ufoo -h localhost

sudo -u postgres psql postgres

# user foo login to postgres db
psql -Ufoo -h localhost -d postgres

遵循以下步骤:

Sudo -u postgres -i psql postgres \密码

之后,输入两次密码。

然后在pgAdmin4中使用该密码。

尽量不要使用-W参数,并让密码为空。有时创建用户时使用无密码。

如果不行,重置密码。有几种方法可以做到这一点,但这适用于许多系统:

$ su root
$ su postgres
$ psql -h localhost
> ALTER USER postgres with password 'YourNewPassword';

这是由于缓存造成的。

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

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

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

查看原文

运行laravel迁移时密码验证失败错误