为了账号安全,请及时绑定邮箱和手机立即绑定

Postgresql:用户“postgres”的密码验证失败

Postgresql:用户“postgres”的密码验证失败

Postgresql:用户“postgres”的密码验证失败我安装了PostgreSQL 8.4,Postgres客户端和Pgadmin 3.对于控制台客户端和Pgadmin用户“postgres”的身份验证失败。我输入的用户为“postgres”,密码为“postgres”,因为之前有效。但现在身份验证失败了。我之前做过几次没有这个问题。我该怎么办?会发生什么?psql -U postgres -h localhost -WPassword for user postgres: psql: FATAL:  password authentication failed for user "postgres"FATAL:  password authentication failed for user "postgres"
查看完整描述

3 回答

?
慕容3067478

TA贡献1773条经验 获得超3个赞

如果我没记错的话,默认情况下用户postgres没有在Ubuntu上设置DB密码。这意味着,您只能使用postgres 操作系统用户帐户登录该帐户。

假设您可以root访问该框,您可以执行以下操作:

sudo -u postgres psql

如果失败并出现database "postgres" does not exists错误,那么您很可能不在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。那也没关系。

psqlshell中,您可以为DB用户 postgres提供密码:

ALTER USER postgres PASSWORD 'newPassword';

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

现在你应该能够为pgAdmin提供DB超级用户的有效密码,它也会很开心。:-)


查看完整回答
反对 回复 2019-07-23
?
湖上湖

TA贡献2003条经验 获得超2个赞

工作人员的反应是正确的,但如果你想进一步自动化可以做到:

$ sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'postgres';"

完成!您保存了User = postgres和password = postgres。

如果您没有用户postgres ubuntu的密码,请执行以下操作:

$ sudo passwd postgres


查看完整回答
反对 回复 2019-07-23
  • 3 回答
  • 0 关注
  • 8446 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信