Tuesday, 6 November 2018

How to deploy local MySQL database to Heroku

I'm new to using Heroku and I have a Ruby/Sinatra app in which I plan on using a MySQL database as the main data store.
However, I do not want to write results directly to the database on Heroku. Instead, I want to write the results to a local database, and then be able to easily deploy/update/copy my local DB to the "production" database on Heroku.

 Answers


Firstly Heroku natively uses postgres. Life will be easier for you if you use that locally.
You can import / export postgres dump files from heroku as described here: https://devcenter.heroku.com/articles/heroku-postgres-import-export
If you really want to use mysql, you have two paths to follow.
1) Run mysql locally, but convert to postgres when migrating to Heroku using the mysql2psql gem, as described here: https://devcenter.heroku.com/articles/heroku-mysql
2) Use a mysql addon like https://addons.heroku.com/cleardb
However my recommendation would be to use postgres end to end, as it is baked into Heroku, and you'll be working with the default ways of using Heroku, not against them.

0 comments:

Post a Comment