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

时间:2014-03-14 13:37:46

标签: ruby-on-rails ruby postgresql heroku

我正在尝试在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.

那么,如何正确提取数据?

2 个答案:

答案 0 :(得分:7)

根据Heroku Postgres help,您必须指定要从中移除的数据库,以便pg:pull能够正常工作。

$ heroku pg:pull HEROKU_POSTGRESQL_MAGENTA mylocaldb --app sushi

此命令将创建一个名为mylocaldb的新本地数据库,然后从应用程序DATABASE_URL的{​​{1}}数据库中提取数据。为防止意外数据覆盖和丢失,本地数据库不得存在。在继续之前,系统将提示您删除已存在的本地数据库。

这也假设您在本地计算机上安装了Postgres。

sushi会在Heroku数据库中为您提供所有可用信息,例如姓名。

答案 1 :(得分:0)

在项目的目录中,安装水龙头之后,您可以尝试使用

taps server `heroku config:get DATABASE_URL` db db

启动点击服务器,然后

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

通过点击将本地数据库同步到heroku

相关问题