2015-02-09 168 views
3

當我嘗試連接到使用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

回答

4

首先,找到你的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