致命:用户“购物”的对等身份验证失败

时间:2016-09-03 10:39:00

标签: ruby-on-rails postgresql

我做了什么:

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

然后我从GitHub(一个使用pg的rails应用程序)克隆了一个存储库,bundle install,编辑database.yml来编写我的密码,现在在rake db:create之后(同时setup并且migrate)不起作用。

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

2 个答案:

答案 0 :(得分:8)

请将主机添加到您的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

答案 1 :(得分: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。对等身份验证

     

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

相关问题