无法在Linux Centos上使用postgresql对用户进行身份验证

时间:2016-05-09 19:24:33

标签: ruby-on-rails postgresql centos

PG 9.4 Centos 6.7

我在Centos上成功安装了Postgres 9.4。我正在通过pgAdmin检查我的身份验证。我可以使用Centos终端创建新用户等。

但是,在创建用户和密码后,我无法使用它们访问Postgres上的localhost。我收到错误:'致命:用户“pguser”'

的身份验证失败

奇怪的是,我可以使用我的linux用户名和无密码登录。但是,只要我创建新的用户名和密码,它就不起作用。

/var/lib/pgsql/9.4/data/pg_hba.conf文件,如password authentication failed for user "postgres"所示:

# Database administrative login by UNIX sockets
local   all         postgres                          ident
# TYPE  DATABASE        USER            ADDRESS                 METHOD
# "local" is for Unix domain socket connections only
local   all             all                                     md5
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5

如何设置正确验证的新超级用户和密码? (此用户将用于在rails应用程序的ruby中读取/写入pg)

编辑:下面提供的答案有效。您可能必须重新启动计算机或找到一种杀死/重新启动pg的好方法,看起来有时候pg_hba.conf文件的更改不会。

1 个答案:

答案 0 :(得分:1)

您需要将pg_hba.conf文件配置为接受密码作为进入的METHOD。如果我正确读取此信息,您将尝试使用您配置的用户和密码在本地登录postgres。所以你应该这样配置pg_hba.conf:

# Database administrative login by UNIX sockets
local   all         postgres                          ident
# TYPE  DATABASE        USER            ADDRESS                 METHOD
# "local" is for Unix domain socket connections only
local   all             all                                     password

完成此操作后,您应该能够使用用户名和密码在本地登录。

相关问题