问题描述
我成功地在CentOS服务器上安装了PostgreSQL Server 8.4. 之后,我使用" Postgres"用户登录到CentOS服务器,但是我无法运行任何命令,发生错误:
用户" postgres"的密码身份验证失败
这是pg_hba.conf和postgresql.conf中的一些配置:
--------------------configuration in postgresql.conf----------- listen_addresses = '*' --------------------configuration in pg_hba.conf--------------- local all all md5 local all postgres md5 host all all 127.0.0.1/32 md5 host all all ::1/128 md5
推荐答案
我倾向于在pg_hba.conf中使用以下内容:
# Database administrative login by UNIX sockets local all postgres ident # TYPE DATABASE USER CIDR-ADDRESS METHOD local all all md5 host all all 127.0.0.1/32 md5 host all all ::1/128 md5
这意味着一旦您" Postgres",您就不需要密码,但是您需要Sudo的权利才能成为Postgres,因此这是非常安全的.任何其他用户都可以使用简单的MD5身份验证登录,这意味着您不必在整个地方进行Sudo.这对我来说很好.
其他推荐答案
确保您使用Postgres Postgresql帐户的密码,而不是Postgres系统帐户.尝试在pg_hba.conf中的"信任",而不是" md5"以连接到db a更改您的通行证.
其他推荐答案
我遇到了一个类似的问题(相同的错误消息).就像丹尼尔的回答一样,这是因为我在以下方面感到困惑:
" Postgres Postgresql帐户,而不是Postgres系统帐户."
要确定Postgres密码,只需将其更改为" 123456"(或任何其他密码)
# su postgres # psql -d template1 template1=# ALTER USER postgres WITH PASSWORD '123456';
问题描述
I have installed PostgreSQL server 8.4 on my CentOS server sucessfully. After that, I login to CentOS server by using 'postgres' user, but I can not run any command, the error occur:
password authentication failed for user "postgres"
Here is some configurations in pg_hba.conf and postgresql.conf:
--------------------configuration in postgresql.conf----------- listen_addresses = '*' --------------------configuration in pg_hba.conf--------------- local all all md5 local all postgres md5 host all all 127.0.0.1/32 md5 host all all ::1/128 md5
推荐答案
I tend to use the following in pg_hba.conf:
# Database administrative login by UNIX sockets local all postgres ident # TYPE DATABASE USER CIDR-ADDRESS METHOD local all all md5 host all all 127.0.0.1/32 md5 host all all ::1/128 md5
That means that once you're "postgres", you don't need a password, but you need sudo rights to become postgres, so that's pretty darn secure. Any other user can login using simple md5 authentication, which means you don't have to sudo all over the place. This works well for me.
其他推荐答案
Ensure you use the password of the postgres PostgreSQL account, not the postgres system account. Try "trust" instead of "md5" in the pg_hba.conf to connect to the db an change your pass.
其他推荐答案
I met a similar problem (the same error message). Like Daniel answer, it's because that I confuse between :
"postgres PostgreSQL account, not the postgres system account."
To be sure about the postgres password, just change it to '123456' (or any other password)
# su postgres # psql -d template1 template1=# ALTER USER postgres WITH PASSWORD '123456';