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

当前回答

时间过得真快啊!

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

local   all             postgres                                password

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

其他回答

我也遇到过类似的问题。 Ubuntu让我用超级用户的任何密码登录控制台。 除了我在psql行命令中连接-h localhost。

我还观察到“localhost:8080/MyJSPSiteLogIn”-显示:致命:用户“user”的autentication错误。

Pg_hba.conf是ok的。

我注意到在同一个服务中运行了两个版本的postgres。

解决-卸载inutil版本。

进入postgres shell后,输入以下命令

postgres=# \password 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选项进行连接。

编辑pg_hba.conf文件,Debian在/etc/postgresql/9.3/main/pg_hba.conf, Red Hat/IBM在/var/lib/pgsql/9.4/data/pg_hba.conf

将所有身份验证方法更改为信任。 修改Linux postgres用户密码。 重新启动服务器。 使用psql -h localhost -U postgres登录,并使用刚才设置的Unix密码。 如果它工作,你应该重新设置pg_hba.conf文件的值md5或ident方法,并重新启动。