收到错误:尝试使pgsql使用rails时,用户"postgres"的对等身份验证失败 [英] Getting error: Peer authentication failed for user "postgres", when trying to get pgsql working with rails

查看:124
本文介绍了收到错误:尝试使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文档上的两个选项的简短描述.身份验证方法.

对等身份验证方法通过获取客户端的 内核中的操作系统用户名,并将其用作允许的用户名 数据库用户名(带有可选的用户名映射).这个方法是 仅在本地连接上受支持.

The peer authentication method works by obtaining the client's operating system user name from the kernel and using it as the allowed database user name (with optional user name mapping). This method is only supported on local connections.

密码验证

基于密码的身份验证方法是md5和password.这些 除了密码发送的方式外,其他方法的操作方式相似 跨连接,分别是MD5哈希值和明文.

The password-based authentication methods are md5 and password. These methods operate similarly except for the way that the password is sent across the connection, namely MD5-hashed and clear-text respectively.

如果您完全关心密码嗅探"攻击,则为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"的对等身份验证失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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