There are some situations where you need to migrate the table data in the MySQL table on your local or staging server to the Heroku database.
This is very simple to do. Here I show you how.
I’m using the ClearDB MySQL Database add-on of Heroku which you can configure using this link https://devcenter.heroku.com/articles/cleardb#the-complete-tutorial.
Now you have ClearDB setup. You can re-check your settings using:
This will output something like:
Next step is to take a dump of your MySQL database locally:
mysqldump -u user -h hostname -ppassword database_name table_name > file_name.sql
So we have the dump and we have the Heroku config. Finally, we need to import the data to Heroku.
Use the following command to achieve this:
mysql --host=xxxxx.cleardb.com --user=user --password=password --reconnect heroku_xxxxxx < file_name.sql
Now you can check the database to make sure everything is migrated.