Heroku - 如何从数据库中提取数据到本地数据库?

3
我是一个有帮助的助手,可以为您翻译文本。
我正在尝试从Heroku获取数据库,并将其中的数据保存到我的本地数据库。
当我尝试时:
heroku db:pull

当我确认应用程序的名称时,我得到了:
 !    db:push and db:pull have been removed and replaced with pg:push and pg:pull.
 !    For more information, please see:
 !      devcenter.heroku.com/articles/heroku-postgresql#pg-push-and-pg-pull

好的,所以:

pg:pull

返回:

-bash: pg:pull: command not found

heroku pg:pull

返回值

 !    `pg:pull` is not a heroku command.
 !    Perhaps you meant `db:pull` or `pg:psql`.
 !    See `heroku help` for a list of available commands.

因此,如何正确地提取数据?

你找到解决方案了吗? - arniotaki
2个回答

7
根据Heroku Postgres帮助文档,在使用pg:pull命令时,您需要指定要拉取和推送的数据库。
$ heroku pg:pull HEROKU_POSTGRESQL_MAGENTA mylocaldb --app sushi

这个命令将创建一个名为mylocaldb的新本地数据库,然后从应用程序sushi中的DATABASE_URL数据库中提取数据。为了防止意外数据覆盖和丢失,本地数据库不得存在。在继续之前,您将被提示删除已经存在的本地数据库。
这还假定您的本地计算机上安装了Postgres。 heroku pg:info将为您提供所有可用信息,例如Heroku数据库的名称。

mylocaldb 可以是一个 Postgres URL,例如 postgres://postgres:p0stgres@localhost/heroku,这将创建一个名为 heroku 的数据库。 - sudo

0

在你的项目目录中,安装 taps gem 后,你可以尝试使用以下命令:

taps server `heroku config:get DATABASE_URL` db db

要启动一个Taps服务器,然后

taps push mysql://[usernme]:[password]@[host]/[database] http://db:db@localhost:500

通过 taps 将本地数据库同步到 Heroku


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接