PG :: ConnectionBad:fe_sendauth:没有密码提供 [英] PG::ConnectionBad: fe_sendauth: no password supplied
问题描述
当我尝试在本地Postgres数据库运行耙测试,它抛出上述异常。
When I attempt to run "rake test" on a local postgres database, it throws the above exception.
下面是我的pg_hba.conf文件:
#数据库由Unix域套接字管理登录
当地所有同行的Postgres
Here is my pg_hba.conf file: # Database administrative login by Unix domain socket 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中的相关部分。
and here is the relevant section from my database.yml
test:
adapter: postgresql
database: myapp_test
pool: 5
timeout: 5000
host: localhost
username: username
password:
在实际的database.yml,用户名被替换为我记录在我的实际用户名。由于认证方法被定义为对等,没有密码应符合规定。
In the real database.yml, 'username' is replaced with my actual user name that I am logged in as. Since the authentication method is defined as 'peer', no password should be required.
我也照顾到重新启动的Postgres
I have also taken care to restart Postgres
sudo -u postgres pg_ctlcluster 9.3 main restart
还有什么我在这里丢失?
What else am I missing here?
推荐答案
本地主机
作为主机指的是TCP连接,这意味着在auth方法是 MD5
(需要密码),按你的的pg_hba.conf
:
localhost
as a host refers to a TCP connection, which means the auth method is md5
(password required) per your pg_hba.conf
:
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
对于等
将要采取的方法,你需要通过Unix域套接字连接,因为你似乎可以用一个debian-OS一样,这意味着把 / var / run中/ PostgreSQL的
在主机
字段,或者什么都没有(这是默认的,除非环境变量说其他)。
For the peer
method to be taken, you'd need to connect through Unix domain sockets, and since you seem to be using a debian-like OS, that means putting /var/run/postgresql
in the host
field, or nothing at all (it's the default unless environment variables say otherwise).
这篇关于PG :: ConnectionBad:fe_sendauth:没有密码提供的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!