尝试为 ror 应用程序设置 postgres,出现错误 - fe_sendauth:未提供密码应用程序、出现错误、密码、ror

2023-09-06 22:45:02 作者:握不住的沙,干脆散啦它

获取:

An error has occurred:

Error connecting to the server: fe_sendauth: no password supplied

database.yml中的设置与其他机器上的应用设置相同.

Settings in database.yml are the same as the app setup on other machines.

如何进行设置,这样我就不需要硬编码密码了?

How can I set things up so that I don't need a password hardcoded?

我可以使用 PgAdmin-III 查看数据库.

I can view the db ok using PgAdmin-III.

我宁愿在 database.yml 中没有密码,因为使用此应用程序的其他机器没有/不需要它,所以这似乎与我的 Pg 安装有关.

I'd rather not have the password in database.yml as other machines using this app don't have/need it, so it seems likely to be something about my Pg install.

推荐答案

你需要改变你的改变你的pg_hba.conf.这是我的一个例子:

You need to change your change your pg_hba.conf. Here's an example of mine:

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

请注意,trust 意味着 address 上的任何人(在本例中为 localhost)都可以作为列出的用户(或在本例中为他们选择的任何用户)进行连接.这实际上只适用于数据不重要的开发配置.不要在生产中使用它.

Note that trust means 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.