PG :: ConnectionBad:FATAL:对等身份验证失败,用户名“的错误

问题描述:

当我尝试连接到使用User.connection或仿制table.connection我得到这个错误PG :: ConnectionBad:FATAL:对等身份验证失败,用户名“的错误

PG :: ConnectionBad我PG数据库:致命:用户'用户名'对等身份验证失败

我仔细检查了我的database.yml,它看起来不错。我认为问题在于我的pg_bha.conf文件?我现在无法在我的应用程序或我的系统中找到此文件。

的database.yml

development: 
    adapter: postgresql 
    encoding: utf8 
    database: project_development 
    pool: 5 
    username: 
    password: 

test: &TEST 
    adapter: postgresql 
    encoding: utf8 
    database: project_test 
    pool: 5 
    username: name 
    password: 

production: 
    adapter: postgresql 
    encoding: utf8 
    database: project_production 
    pool: 5 
    username: name 
    password: 

cucumber: 
    <<: *TEST 
    Thanks for the help. 
+1

你可以发布你的database.yml代码 – Sontya 2015-02-09 13:56:28

首先,找到你的pg_hba.conf:

sudo find/-name "pg_hba.conf"

这是/var/lib/pgsql/data/pg_hba.conf在我的系统上。

确保改变这一行pg_hba.conf中:

local all all local

到:

local all all md5

最后,重启PostgreSQL的:

OS X:

launchctl unload ~/Library/LaunchAgents/org.postgresql.postgres.plist

launchctl load ~/Library/LaunchAgents/org.postgresql.postgres.plist

Systemd:

sudo systemctl restart postgresql.service

的SysVinit:

sudo service postgresql restart

+0

在Ubuntu 14.04下,使用上面的SysVinit命令重新启动你的PostgreSQL服务。此外,非常感谢,这非常有效。 – 2016-08-01 09:14:31