Rails app using Mysql how to deploy with heroku?
How to deploy a Rails app using Mysql on heroku?
I find out that my开发者_StackOverflow社区 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
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:adf4234@us-cdbr-east.cleardb.com/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:adf4234@us-cdbr-east.cleardb.com/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:adf4234@us-cdbr-east.cleardb.com/heroku_db?reconnect=true'
$ heroku config:set CLEARDB_DATABASE_URL='mysql2://adffdadf2341:adf4234@us-cdbr-east.cleardb.com/heroku_db?reconnect=true'
Please follow: https://devcenter.heroku.com/articles/cleardb for more information
Hope that can help you.
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.
精彩评论