简体   繁体   中英

Heroku - how to pull data from database to the local database?

I am trying to fetch database on Heroku and the data from there to save into my local database.

When I try

heroku db:pull

and confirm the name of the app, I get:

 !    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

Ok, so:

pg:pull

returns:

-bash: pg:pull: command not found

heroku pg:pull

returns

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

Thus, how to properly pull the data?

Per the Heroku Postgres help , you have to specify the database you are pulling from and to for pg:pull to work.

$ heroku pg:pull HEROKU_POSTGRESQL_MAGENTA mylocaldb --app sushi

This command will create a new local database named mylocaldb and then pull data from the database at DATABASE_URL from the app sushi . To prevent accidental data overwrites and loss, the local database must not exist. You will be prompted to drop an already existing local database before proceeding.

This also assumes you have Postgres on your local machine.

heroku pg:info will give you all available information, such as name, on your Heroku databases.

in your project's dir, after installing taps gem, you can try using

taps server `heroku config:get DATABASE_URL` db db

to start a taps server, and then

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

to sync local db to heroku through taps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM