2016-09-03 27 views
1

我所做的:FATAL:對等身份驗證失敗,用戶「店」

sudo -u postgres psql 
CREATE ROLE shop CREATEDB LOGIN PASSWORD 'kurt1245'; 

然後我克隆從GitHub(使用PG Rails應用程序),bundle install存儲庫,編輯database.yml寫我的密碼,現在rake db:create(也setupmigrate)不起作用。

database.yml

development: adapter: postgresql encoding: unicode database: shop_development pool: 5 username: shop password: kurt1245 test: adapter: postgresql encoding: unicode database: shop_test pool: 5 username: shop password: kurt1245

+0

重複的:http://stackoverflow.com/questions/18664074/getting-error-peer-authentication-failed-for-user-postgres-when-trying-to-ge – Loqman

回答

6

我有同樣的錯誤幾天就回來。

編輯/etc/postgresql/$version/main/pg_hba.conf

您可以檢查你的PSQL控制檯中使用爲select VERSION();

pg_hba.conf變化

local all postgres peer

什麼版本:

local all postgres md5

Peer Authentication explained

19.3.7。等驗證

的對等身份驗證方法的工作原理是從內核獲取客戶端的 操作系統的用戶名,並用它作爲允許 數據庫的用戶名(帶有可選的用戶名映射)。此方法僅在本地連接上支持 。

6

請將主機添加到您的database.yml文件中。希望它能幫助你。

development: 
    adapter: postgresql 
    encoding: unicode 
    host: localhost 
    database: shop_development 
    pool: 5 
    username: shop 
    password: kurt1245 

test: 
    adapter: postgresql 
    encoding: unicode 
    host: localhost 
    database: shop_test 
    pool: 5 
    username: shop 
    password: kurt1245