'用户“postgres"的密码认证失败' [英] 'password authentication failed for user "postgres"'

查看:341
本文介绍了'用户“postgres"的密码认证失败'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

psql -U postgres -h localhost -W用户 postgres 的密码:psql:致命:用户postgres"的密码身份验证失败致命:用户postgres"的密码验证失败

解决方案

如果我没记错,用户 postgres 默认没有在 Ubuntu 上设置 DB 密码.这意味着,您只能使用 postgres OS 用户 帐户登录到该帐户.

假设您对可以执行的框具有 root 访问权限:

sudo -u postgres psql

如果失败并出现 database "postgres" does not exist 错误,那么您很可能不在 Ubuntu 或 Debian 服务器上:-) 在这种情况下,只需添加 template1代码>到命令:

sudo -u postgres psql template1

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

本地所有 postgres 标识

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

psql shell 中,你可以给 DB 用户 postgres 一个密码:

ALTER USER postgres PASSWORD 'newPassword';

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

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

I have installed PostgreSQL 8.4, Postgres client and Pgadmin 3. Authentication failed for user "postgres" for both console client and Pgadmin. I have typed user as "postgres" and password "postgres", because it worked before. But now authentication is failed. I did it before a couple of times without this problem. What should I do? And what happens?

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"

解决方案

If I remember correctly the user postgres has no DB password set on Ubuntu by default. That means, that you can login to that account only by using the postgres OS user account.

Assuming, that you have root access on the box you can do:

sudo -u postgres psql

If that fails with a database "postgres" does not exists error, then you are most likely not on a Ubuntu or Debian server :-) In this case simply add template1 to the command:

sudo -u postgres psql template1

If any of those commands fail with an error psql: FATAL: password authentication failed for user "postgres" then check the file /etc/postgresql/8.4/main/pg_hba.conf: There must be a line like this as the first non-comment line:

local   all         postgres                          ident

For newer versions of PostgreSQL ident actually might be peer. That's OK also.

Inside the psql shell you can give the DB user postgres a password:

ALTER USER postgres PASSWORD 'newPassword';

You can leave the psql shell by typing CtrlD or with the command \q.

Now you should be able to give pgAdmin a valid password for the DB superuser and it will be happy too. :-)

这篇关于'用户“postgres"的密码认证失败'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆