pg_restore -h localhost vs pg_restore -h 127.0.0.1

发布于 2025-01-25 12:59:07 字数 853 浏览 0 评论 0原文

我正在关注一个有关从Heroku应用下载数据库并将其与您的本地版本配对的教程。这是一个过程:

要查看Heroku中的数据库,

heroku pg:backups

下载

heroku pg:backups:capture

以将公共URL

heroku pg:backups public-url

curl `heroku pg:backups public-url`> heroku.dump

对DB与本地仓库

rails db:drop db:create

。然后运行Postgres Restore命令,

pg_restore --verbose --clean --no-acl --no-owner -h localhost -d <YOUR DB NAME> ./heroku.dump

现在我有一个情况,当我使用localhost启动服务器时,我可以访问该应用程序并查看添加的数据库记录。但是,如果我从127.0.0.1:3000启动服务器,则该应用程序仍可访问,但没有检索数据。

我以为Localhost和127.0.0.1基本上没有什么不同?

更新

所以我意识到为什么这个问题使人感到困惑……而且我相信我现在对我的问题有答案:

localhost和127.0.0.1是相同的,但我的Rails应用程序中的配置正在定义Localhost作为端口。这就是为什么使用Localhost时显示数据但使用127.0.0.1时不会显示的原因。

I was following a tutorial about downloading a db from a heroku app and pairing it with your local version. This was the process:

To view database in Heroku

heroku pg:backups

To download

heroku pg:backups:capture

Public URL

heroku pg:backups public-url

curl `heroku pg:backups public-url`> heroku.dump

Pair db with local repo.

rails db:drop db:create

then run postgres restore command

pg_restore --verbose --clean --no-acl --no-owner -h localhost -d <YOUR DB NAME> ./heroku.dump

Now I have a situation, when I launch a server using localhost, I can access the app and see the added database records. But if I launch a server from 127.0.0.1:3000 , the app is still accessible but no data is retrieved.

I thought that localhost and 127.0.0.1 are not essentially different from each other?

UPDATE

So I have realised why this question is confusing people... and I believe I now have the answer to my question:

localhost and 127.0.0.1 are the same but the configuration in my Rails app is defining localhost as the port to listen to. That is why data is showing up when using localhost but not showing up when using 127.0.0.1.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文