2011-08-12 240 views
13

我在CentOS服务器上成功安装了PostgreSQL服务器8.4。 在那之后,我登录到CentOS的服务器通过使用“Postgres的用户,但我不能运行任何命令,出现错误:用户“postgres”的密码验证失败

密码验证失败的用户“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 

回答

11

确保您使用的Postgres的PostgreSQL帐户的密码,而不是Postgres系统帐户。尝试“信任”,而不是“md5”在pg_hba.conf连接到数据库更改您的通行证。

+0

什么Postgres的系统帐户和Postgres PostgreSQL的帐户之间的区别?以及如何检查我是否使用postgres PostgreSQL帐户? –

+0

你应该知道你使用哪个密码。 – Daniel

+0

我已经使用PostgreSQL帐户的密码。 –

14

我倾向于使用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。这对我很好。

8

我遇到了类似的问题(相同的错误信息)。像丹尼尔回答,这是因为我混淆之间:

“postgres PostgreSQL帐户,而不是postgres系统帐户。”

可以肯定的关于Postgres密码,只需将其更改为“123456”(或任何其他密码)

# su postgres 
# psql -d template1 
template1=# ALTER USER postgres WITH PASSWORD '123456'; 
相关问题