PostgreSQL fe_sendauth:未提供密码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27419961/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PostgreSQL fe_sendauth: no password supplied
提问by mbajur
I know there are thousands of questsions like this one here on SO but i've seen them all and i'm still not able to deal with my problem.
我知道 SO 上有成千上万个这样的问题,但我已经看到了所有问题,但我仍然无法解决我的问题。
I'm doing everything using ansible so it's quite automated but, anyway, here are my files:
我正在使用 ansible 做所有事情,所以它非常自动化,但无论如何,这是我的文件:
pg_hba.conf
pg_hba.conf
local all all trust
host all all 127.0.0.1/32 md5
host all all ::1/128 md5
host all all 10.11.12.0/24 md5
database.yml
数据库.yml
production:
database: my_db
adapter: postgresql
host: localhost
username: deploy
encoding: unicode
min_messages: WARNING
template: template0
And i have a deploy
user (and postgres user without a password set) in my system created. And now, while i'm totally able to sign in to postgres from bash using psql -d my_db
(on server), i'm not able to connect to the db with my rails app. Running rake db:migrateMigration gives me
我deploy
在我的系统中创建了一个用户(和没有设置密码的 postgres 用户)。现在,虽然我完全能够使用psql -d my_db
(在服务器上)从 bash 登录到 postgres ,但我无法使用我的 rails 应用程序连接到数据库。运行 rake db:migrateMigration 给了我
PG::ConnectionBad: fe_sendauth: no password supplied
I'm quite terrible at beeing a devop and i'm fighting with that issue from the day before yesterday's morning and it's still here so if there is anyone who can help me with that, i would be be more than grateful.
我在开发 Devop 方面非常糟糕,我从前天早上开始就在与这个问题作斗争,它仍然存在,所以如果有人可以帮助我解决这个问题,我将不胜感激。
采纳答案by Frank Heikens
psql is using a local socket connection, rails is using localhost over TCP/IP. Local is trusted, localhost requires a password (using md5). You could setup a pgpass file for your rails user: http://www.postgresql.org/docs/current/static/libpq-pgpass.html
psql 使用本地套接字连接,rails 使用 TCP/IP 上的 localhost。本地是可信的,localhost 需要密码(使用 md5)。您可以为您的 rails 用户设置一个 pgpass 文件:http: //www.postgresql.org/docs/current/static/libpq-pgpass.html
回答by Alan Corey
In C you can do it like this, I don't even know what Rails is
在 C 中你可以这样做,我什至不知道 Rails 是什么
conninfo = "hostaddr = 127.0.0.1 dbname = bitcoin user = alan password = mypass";
conn = PQconnectdb(conninfo);
I had exactly the same error message.
我有完全相同的错误消息。