【发布时间】:2014-06-16 01:04:42
【问题描述】:
当我尝试在本地 postgres 数据库上运行“rake test”时,它会引发上述异常。
这是我的 pg_hba.conf 文件: # 通过 Unix 域套接字进行数据库管理登录 本地所有 postgres 节点
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all username peer
local myapp_dev myapp md5
local myapp_test myapp md5
local myapp_prod myapp md5
#local all all peer
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local replication postgres peer
#host replication postgres 127.0.0.1/32 md5
#host replication postgres ::1/128 md5
这是我的 database.yml 中的相关部分
test:
adapter: postgresql
database: myapp_test
pool: 5
timeout: 5000
host: localhost
username: username
password:
在真实的 database.yml 中,“用户名”被替换为我登录时使用的实际用户名。由于身份验证方法被定义为“对等”,因此不需要密码。
我也注意重启 Postgres
sudo -u postgres pg_ctlcluster 9.3 main restart
我还缺少什么?
【问题讨论】:
标签: ruby-on-rails postgresql authentication