【发布时间】:2018-01-16 21:32:09
【问题描述】:
看在上帝的份上,我无法理解为什么 postgres 抱怨密码验证(使用 ActiveRecord)。
sudo -u postgres psql rdb
这项工作(不要求密码)
local all postgres peer
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
host all all 127.0.0.1/32 md5
但是当连接像 ActiveRecord 这样的 ORM 时,它会报错。
ActiveRecord::Base.establish_connection(adapter: 'postgresql', username: 'postgres', database: 'rdb')
The server requested password-based authentication, but no password was provided.
这是一个基本设置,我一直希望它能够正常工作。我最后的手段是允许 trust 或 md5(在 pg_hba.conf 上),但在我继续之前,请向我提供一些关于为什么上述方法不起作用的指针。
刚刚更新 postgres 在 localhost 运行
【问题讨论】:
标签: ruby-on-rails postgresql activerecord