heroku db: 当我未指定密码时,由于缺少密码而导致拉取失败

发布于 2024-12-08 12:28:05 字数 1265 浏览 0 评论 0原文

当我执行 heroku db:pull 时,它会在以下位置找到我的本地开发数据库:

postgres://127.0.0.1/myapp_development?encoding=utf8

一旦我确认,它就会失败:

Sequel::DatabaseConnectionError -> PGError: fe_sendauth: no password supplied

我尝试使用指定的本地数据库运行拉取,例如

heroku db:pull postgres://root:@localhost/db_name

,这给出了相同的“未提供密码”错误。

我想我可能需要将 root: 更改为 myname: 因为这是我在设置 postgres 时授予超级用户权限的用户,但 root: 或 myname: 都不起作用

我的database.yml 对于指定的所有数据库来说,用户名: 和密码: 为空。

从命令行作为 myname@ubuntu 我可以输入 psql myapp_development 并正常连接并运行选择。

我在这里缺少什么?

与我的pg_hba.conf设置有关吗?我看了一下里面,它说:

# Database administrative login by UNIX sockets
local   all         postgres                          ident

# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD

# "local" is for Unix domain socket connections only
local   all         all                               ident
# IPv4 local connections:
host    all         all         127.0.0.1/32          md5
# IPv6 local connections:
host    all         all         ::1/128               md5

应该在那里使用“可信”吗?如果是这样,如果我编辑该文件,我需要重新启动 postgres 吗?如果“信任”是必要的,那么当以 myname 用户身份登录时,rails 和 psql 命令行工具如何在没有密码的情况下工作?

谢谢你!

When I execute heroku db:pull it finds my local dev db at:

postgres://127.0.0.1/myapp_development?encoding=utf8

once I confirm though, it fails with:

Sequel::DatabaseConnectionError -> PGError: fe_sendauth: no password supplied

I tried running the pull with the local db specified, e.g.

heroku db:pull postgres://root:@localhost/db_name

which gives the same no password supplied error.

I thought I may need to change root: to myname: because thats the user I granted superuser rights to when I setup postgres but neither root: or myname: works

My database.yml has username: and password: blank for all databases specified.

From the command line as myname@ubuntu I can type psql myapp_development and connect fine and run selects.

What am I missing here?

Is it related to my pg_hba.conf settings? I had a look inside that and it says:

# Database administrative login by UNIX sockets
local   all         postgres                          ident

# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD

# "local" is for Unix domain socket connections only
local   all         all                               ident
# IPv4 local connections:
host    all         all         127.0.0.1/32          md5
# IPv6 local connections:
host    all         all         ::1/128               md5

Should 'trusted' be used there? And if so if I edit that file do I need to restart postgres? And if 'trust' is necessary then how come rails and the psql command line tools work without passwords when logged in as my myname user?

Thank you!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

只等公子 2024-12-15 12:28:05

身份验证方法 trust 可能可以解决问题,但您无疑知道,这并不安全。
编辑 pg_hba.conf 后,您无需重新启动。 A 重新加载< /strong> 就足够了(引用手册):

pg_hba.conf 文件在启动时和主服务器启动时读取
进程收到 SIGHUP 信号。如果您在活动状态下编辑文件
系统,您需要向 postmaster 发出信号(使用 pg_ctl reload 或
kill -HUP) 使其重新读取文件。

pg_ctl reload

请参阅详细手册。您可能需要 8.3 版本的手册。 heroku 上的共享数据库当前在 PostgreSQL 8.3 上运行。 (另外,我怀疑你是否有权访问heroku上的pg_ctl。)

请注意 这个

如果用户没有设置密码,则存储的密码为空
并且该用户的密码身份验证始终会失败

强调我的。您也许能够在本地登录,因为 auth-方法 identpeer 允许这样做。但为了您的目的,您可能需要密码!

Authentication method trust might do the trick, but as you are undoubtedly aware, this is not secure.
After editing pg_hba.conf, you don't have to restart. A reload is enough (quoting the manual):

The pg_hba.conf file is read on start-up and when the main server
process receives a SIGHUP signal. If you edit the file on an active
system, you will need to signal the postmaster (using pg_ctl reload or
kill -HUP) to make it re-read the file.

pg_ctl reload

See the fine manual. You might need the manual for version for 8.3. Shared db on heroku currently runs on PostgreSQL 8.3. (Also, I doubt you have access to pg_ctl on heroku.)

Be aware of this:

If no password has been set up for a user, the stored password is null
and password authentication will always fail for that user.

Emphasis mine. You might be able to log in locally, because the auth-methods ident or peer allow for that. But for your purpose you may need a password!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文