本文介绍了收到错误:尝试使pgsql使用rails时,用户"postgres"的对等身份验证失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了错误:

FATAL: Peer authentication failed for user "postgres"

当我尝试使Postgres与Rails一起使用时.

when I try to make postgres work with Rails.

这是我的 pg_hba.conf ,我的 database.yml ,以及完整跟踪的转储.

我在pg_hba中将身份验证更改为md5,并尝试了其他方法,但似乎没有任何效果.

I changed authentication to md5 in pg_hba and tried different things, but none seem to work.

我还尝试根据

但是它们在pgadmin上甚至在我运行sudo -u postgres psql -l时都不会出现.

But they don't show up on pgadmin or even when I run sudo -u postgres psql -l.

知道我要去哪里错了吗?

Any idea where I'm going wrong?

推荐答案

问题仍然是您的pg_hba.conf文件(/etc/postgresql/9.1/main/pg_hba.conf*).

The problem is still your pg_hba.conf file (/etc/postgresql/9.1/main/pg_hba.conf*).

此行:

local   all             postgres                                peer

应该是:

local   all             postgres                                md5

*如果找不到此文件,请运行locate pg_hba.conf应该会显示文件的位置.

* If you can't find this file, running locate pg_hba.conf should show you where the file is.

更改此文件后,不要忘记重新启动PostgreSQL服务器.如果您使用的是Linux,则为sudo service postgresql restart.

After altering this file, don't forget to restart your PostgreSQL server. If you're on Linux, that would be sudo service postgresql restart.

这些是根据官方PostgreSQL文档上的两个选项的简短描述.身份验证方法.

密码验证

如果您完全关心密码嗅探"攻击,则为md5 是首选.如果可能,应始终避免使用纯密码. 但是,md5不能与db_user_namespace功能一起使用.如果 连接受SSL加密保护,然后可以使用密码 安全(尽管SSL证书身份验证可能是更好的选择 如果一个取决于使用SSL).

If you are at all concerned about password "sniffing" attacks then md5 is preferred. Plain password should always be avoided if possible. However, md5 cannot be used with the db_user_namespace feature. If the connection is protected by SSL encryption then password can be used safely (though SSL certificate authentication might be a better choice if one is depending on using SSL).

pg_hba.conf的示例位置:
/etc/postgresql/9.1/main/pg_hba.conf

Sample location for pg_hba.conf:
/etc/postgresql/9.1/main/pg_hba.conf

这篇关于收到错误:尝试使pgsql使用rails时,用户"postgres"的对等身份验证失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 08:16
查看更多