[英]Rails postgresql DB connection fails
I'm very new to Ruby and postgres. 我是Ruby和Postgres的新手。
Below is my database.yml 下面是我的database.yml
development:
adapter: postgresql
database: test_database
username: postgresql
password: mypassword
host: localhost
encoding: utf8
The user exists and I'm, able to login using same credentials in phpPgadmin. 该用户存在,并且我能够使用phpPgadmin中的相同凭据登录。 But when I start rails server and go to home page of app, I get
FATAL: Ident authentication failed for user "postgresql"
. 但是,当我启动Rails服务器并转到应用程序的主页时,我得到了
FATAL: Ident authentication failed for user "postgresql"
。
Edit: In case pghba.conf matters, 编辑:如果pghba.conf很重要,
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
#local all all peer
local all postgres md5
local all postgresql md5
Could anyone please help ? 有人可以帮忙吗?
open PostgreSQL client authentication configuration file 打开PostgreSQL客户端认证配置文件
vi /var/lib/pgsql/data/pg_hba.conf
This file manage below stuffs 这个文件管理下面的东西
By default Postgresql uses IDENT-based authentication. 默认情况下,Postgresql使用基于IDENT的身份验证。 All you have to do is allow username and password based authentication for your network or webserver.
您要做的就是允许您的网络或Web服务器基于用户名和密码的身份验证。 IDENT will never allow you to login via -U and -W options.
IDENT绝对不允许您通过-U和-W选项登录。 Append following to allow login via localhost only:
追加以下内容以仅允许通过本地主机登录:
local all all trust
host all 127.0.0.1/32 trust
Save and close the file. 保存并关闭文件。 Restart Postgresql server:
重新启动Postgresql服务器:
service postgresql restart OR
sudo /etc/init.d/postgresql restart
It should work 它应该工作
我可以在路径中找到我的pg_hba.conf文件:
/etc/postgresql/8.4/main/pg_hba.conf
对于仍然找不到pg_hba.conf文件的任何人,我使用的是PostgreSQL v9.2,并且在以下位置找到了我的:
/var/lib/pgsql/9.2/data/pg_hba.conf
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.