Heroku is a PaaS, it lets you deploy an app in seconds, almost everything is automated. By default your app will use Heroku shared database, a Postgres db instance which is a perfect choice for development environments, but you just can’t use it in production (just take a look at Heroku status blog to get an idea).
A cheap alternative is Amazon Relational Database Service (RDS). It offers MySQL instances at competitive prices.
To make this service available to your Heroku application you should create a new database instance at Amazon RDS and then enable this resource by adding the relative add-on.
Keep in mind that Heroku dynos are Amazon EC2 instances and should be situated in US-East zone so making a RDS instance in the same zone leads to an optimal communication speed between app server and db server.
Create an RDS database instance, you can do it using web based Amazon RDS console.
Migrate your data from Heroku shared database to your new Amazon RDS database instance.
You’ll need to authorize access to the RDS instance from your workstation running:
1 $ rds-authorize-db-security-group-ingress default --cidr-ip 188.8.131.52/32
where 184.108.40.206/32 is your public IP subnet.
Now you can use
taps to pull from your Heroku database to your RDS database:
1 $ heroku db:pull mysql://user:email@example.com/databasename
Authorize Heroku app access to RDS database
1 2 3 4 $ rds-authorize-db-security-group-ingress --db-security-group-name default \ --ec2-security-group-name default \ --ec2-security-group-owner-id 098166147350 \ --aws-credential-file ../credential-file-path.template
Add Amazon RDS Heroku add-on
1 $ heroku addons:add amazon_rds url=mysql2://user:firstname.lastname@example.org/databasename
If you get
Taps Load Error: no such file to load -- taps/operation error at
“Step 2” no worries, just install
taps on your system by running
1 $ gem install taps
Remember also to update your app’s
Gemfile configuration to load
pg changing from
1 gem 'pg'
1 gem 'mysql2'