Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails app using Mysql how to deploy with heroku?

How to deploy a Rails app using Mysql on heroku?

I find out that my app did not need Amazon RDS (Too expensive for a small app).

Here is my answer how to use Amazon RDS

Heroku help deploying Rails app that uses Mysql database

like image 672
Rails beginner Avatar asked Mar 19 '11 15:03

Rails beginner


2 Answers

Include mysql2 gem in your gemfile:

gem 'mysql2'

Now, your choice can be: https://addons.heroku.com/cleardb add-ons. You can get upto 5mb free storage but you need to fill your credit card information for accessing it.

Steps for using clearDB add-ons are:

# add cleardb add-ons to your app
$ heroku addons:add cleardb:ignite
-----> Adding cleardb to sharp-mountain-4005... done, v18 (free)


# retrieve your database URL:
$ heroku config | grep CLEARDB_DATABASE_URL
CLEARDB_DATABASE_URL => mysql://adffdadf2341:[email protected]/heroku_db?reconnect=true


# copy CLEARDB_DATABASE_URL config variable and set it to your DATABASE_URL config variable
$ heroku config:set DATABASE_URL='mysql://adffdadf2341:[email protected]/heroku_db?reconnect=true'
Adding config vars:
DATABASE_URL => mysql2://adffd...b?reconnect=true
Restarting app... done, v61.

# NOTE: since we are using ```mysql2``` in our gemfile so replace mysql:// scheme in the CLEARDB_DATABASE_URL to mysql2://
$ heroku config:set DATABASE_URL='mysql2://adffdadf2341:[email protected]/heroku_db?reconnect=true'
$ heroku config:set CLEARDB_DATABASE_URL='mysql2://adffdadf2341:[email protected]/heroku_db?reconnect=true'

Please follow: https://devcenter.heroku.com/articles/cleardb for more information

Hope that can help you.

like image 81
przbadu Avatar answered Nov 12 '22 11:11

przbadu


If you do a heroku db:push from your MySql data, it'll automatically get pushed into the heorku PostgreSQL database structure.

You can then do db:pulls and pull back into mysql. Taps provides this database magic.

It's really great -- I'd try it out first before trying to get RDS working.

like image 9
Jesse Wolgamott Avatar answered Nov 12 '22 11:11

Jesse Wolgamott