我已经安装了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"

当前回答

如果你看到错误

FATAL:  password authentication failed for user "postgres"

确保密码正确,检查密码是否有特殊字符,特别是“%”或斜杠。 在我的例子中,它是密码字符串中的“%”。删除此符号后,一切正常。

其他回答

首先是密码箱

ALTER USER postgres with encrypted password 'postgres';

然后重启服务:

sudo systemctl restart postgresql.service

End.

对我来说,这太简单了!我在应用程序JAVA Spring中出错,因为我需要记住数据库超级用户,它在安装过程中显示PostgreSQL,在我的情况下,数据源将是postgres。所以,我正确地添加了名称,它工作!

我只是想补充一句,你也应该检查一下你的密码是否过期了。

详细信息请参见Postgres密码验证失败。

在任何文本编辑器中打开pg_hba.conf(你可以在postgres安装文件夹中找到这个文件); 将所有的方法字段更改为trust(这意味着postgre不需要密码); 在你的控制台运行这个命令: “alter user postgres with password '[my password]';”| psql -U postgres (意思是用参数-U postgres来修改用户[my password]的密码) Et voilà(不要忘记将方法从trust改回最适合你的方法)

我希望有一天这能帮助到别人。

在登录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;