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

当前回答

我希望这能在短时间内帮到你。 可以使用bellow命令修改postgres sql的密码。

命令

sudo -u postgres psql

接下来您可以更新密码

命令

修改用户postgres密码为YOUR_NEW_PASSWORD

其他回答

编辑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方法,并重新启动。

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

postgres=# \password postgres

输入此命令后,将提示您设置密码,只需设置密码,然后尝试。

在我的例子中,它的密码超过100个字符。将其设置为较小的字符密码有效。

事实上,我想知道有没有什么地方提到过这个。

我也遇到过类似的问题。 而访问任何数据库,我得到以下提示后更新密码 " PGAdmin中postgres用户密码认证失败"


解决方案:

关闭postgres服务器 重新运行pgadmin Pgadmin会要求输入密码。 请输入上述用户当前密码

希望它能解决你的问题

如果我没记错的话,默认情况下,用户postgres在Ubuntu上没有设置数据库密码。也就是说,您只能使用postgres操作系统用户帐户登录该帐户。

假设,你有根访问的盒子,你可以做:

sudo -u postgres psql

如果失败,提示数据库“postgres”不存在,那么你很可能不在Ubuntu或Debian服务器上:-)在这种情况下,只需在命令中添加template1:

sudo -u postgres psql template1

如果这些命令中的任何一个失败,出现错误psql: FATAL: password authentication failed for user "postgres",那么检查/etc/postgresql/8.4/main/pg_hba.conf文件:必须有这样的一行作为第一个非注释行:

local   all         postgres                          ident

对于较新版本的PostgreSQL, ident实际上可能是peer。这也没关系。

在psql shell中,你可以给数据库用户postgres设置一个密码:

ALTER USER postgres PASSWORD 'newPassword';

您可以通过键入CtrlD或使用\q命令离开psql shell。

现在,您应该能够为pgAdmin提供一个有效的数据库超级用户密码,它也会很高兴。: -)