Ruby-on-rails 尝试为 ror 应用程序设置 postgres,出现错误 - fe_sendauth:未提供密码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12452073/
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
Trying to set up postgres for ror app, getting error - fe_sendauth: no password supplied
提问by Michael Durrant
Getting:
获得:
An error has occurred:
Error connecting to the server: fe_sendauth: no password supplied
Settings in database.ymlare the same as the app setup on other machines.
中的设置database.yml与其他机器上的应用程序设置相同。
How can I set things up so that I don't need a password hardcoded?
我该如何设置以便我不需要硬编码的密码?
I can view the db ok using PgAdmin-III.
我可以使用 PgAdmin-III 查看数据库。
I'd rather not have the password in database.ymlas other machines using this app don't have/need it, so it seems likely to be something about my Pg install.
我宁愿没有密码,database.yml因为使用这个应用程序的其他机器没有/需要它,所以它似乎与我的 Pg 安装有关。
回答by Rodrigo Zurek
You need to change your change your pg_hba.conf. Here's an example of mine:
你需要改变你的改变你的pg_hba.conf. 这是我的一个例子:
pg_hba.conf:
pg_hba.conf:
TYPE DATABASE USER ADDRESS METHOD
host all all 127.0.0.1/32 trust
host all PC 127.0.0.1/32 trust
host all all ::1/128 trust
Note that trustmeans that anyone on address(in this case localhost) can connect as the listed user (or in this case any user of their choice). This is really only suitable for development configurations with unimportant data. Do not use this in production.
请注意,这trust意味着address(在本例中为 localhost)上的任何人都可以作为列出的用户(或在本例中为他们选择的任何用户)进行连接。这确实只适用于数据不重要的开发配置。不要在生产中使用它。
回答by Hyman
@rodrigo-zurek was spot on; you have to change the pg_hba.conf. Just want to add this answer for the OSX users because the pg_hba.confis located in a different place by default.
@rodrigo-zurek 就在现场;你必须改变pg_hba.conf. 只想为 OSX 用户添加此答案,因为pg_hba.conf默认情况下它位于不同的位置。
sudo su - postgres
vim /Library/PostgreSQL/<YOUR_VERSION>/data/pg_hba.conf
The default will have md5in the column METHOD, but replace all of those with trust:
默认值将md5在列中METHOD,但将所有这些替换为trust:
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
Then, open up pgAdmin III inside your Applications/PostgreSQL 9.X, right click the database (e.g. PostgreSQL 9.4 (localhost)), and click Reload Configuration. After this, I was able to rake db:create.
然后,在 Applications/PostgreSQL 9.X 中打开 pgAdmin III,右键单击数据库(例如PostgreSQL 9.4 (localhost)),然后单击Reload Configuration。在此之后,我能够rake db:create。
回答by Alexey Strizhak
#appveyor.yml
services: postgresql
test_script:
- SET PGUSER=postgres
- SET PGPASSWORD=Password12!
- PATH=C:\Program Files\PostgreSQL.6\bin\;%PATH%
回答by Chris Travers
No password supplied means you have set it up to require password authentication and no password is being supplied. Here is documentation for 9.0: http://www.postgresql.org/docs/9.0/static/auth-methods.html
未提供密码意味着您已将其设置为需要密码验证并且未提供密码。这是 9.0 的文档:http: //www.postgresql.org/docs/9.0/static/auth-methods.html
Keep in mind that local auth was changed from "ident" to "peer" in 9.1 to avoid confusion. See the 9.1 docs at http://www.postgresql.org/docs/9.1/static/auth-methods.html
请记住,本地身份验证在 9.1 中从“ident”更改为“peer”以避免混淆。请参阅http://www.postgresql.org/docs/9.1/static/auth-methods.html 上的 9.1 文档
Also keep in mind that this is an ordered rule set with first match governing. Furthermore local and localhost are different. Local is for local UNIX domain socket connections, while host localhost would be for network connections to localhost. So it sounds like you have some troubleshooting to do but hopefully the docs should help.
还要记住,这是一个有序的规则集,由第一场比赛管理。此外本地和本地主机是不同的。Local 用于本地 UNIX 域套接字连接,而主机 localhost 将用于到 localhost 的网络连接。所以听起来你有一些故障排除要做,但希望文档应该有所帮助。

