这是我的pg_hba.conf文件: #由Unix域套接字进行数据库管理登录 local all postgres peer
# 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文件中,'username'被替换为我实际登录的用户名。由于认证方法被定义为'peer',因此不需要输入密码。
我还特别注意重新启动了Postgres
sudo -u postgres pg_ctlcluster 9.3 main restart
我还错过了什么吗?
peer
方法:"...通过从内核获取客户端操作系统用户名并将其用作允许的数据库用户名来工作..." - x-yuri