Friday, March 11, 2011

Migrating from Heroku Postgres to Amazon RDS MySQL

I recently moved from Heroku's built in postgres database to Amazon RDS to take advantage of Read Replica.

The following steps will get you there, too.

  1. Signup for Amazon RDS
  2. Download the Amazon RDS Command Line Toolkit
  3. Install the Toolkit
    • Unpack toolkit. I did this in /Users/phertler/Applications/RDSCli-1.3.003
    • export AWS_RDS_HOME=/Users/phertler/Applications/RDSCli-1.3.003
    • Make sure you JAVA_HOME is set. export JAVA_HOME=/Library/Java/Home
  4. Configure credentials
    • cp $AWS_RDS_HOME/credential-file-path.template $AWS_RDS_HOME/credential-file.txt
    • Update credential-file.txt with your Amazon Account credentials
  5. Create a security group for your database
    • rds-create-db-security-group --db-security-group-name mygroupname  --db-security-group-description 'my database security group'
  6. Launch a RDS instance with an instance named myinstance database named mytestdb. Be sure to remember your username and password. 
  7. Allow current local machine to connect to your new mysql database
    • rds-authorize-db-security-group-ingress --db-security-group-name mygroupname -i /32
  8. List your instances to be sure you can connect
    • rds-describe-db-instances
  9. Now you can connect to your database from you local machine. You will need to find your RDS instance's endpoint from the AWS console. It will look something like
    • mysql -h -u yourusername -p
Now you are ready to migrate your heroku database to RDS
  1. Allow heroku to connect to your RDS instance
    • rds-authorize-db-security-group-ingress default --ec2-security-group-name database --ec2-security-group-owner-id 098166147350
  2. Add the heroku rds addon
  3. Port your current Heroku Postgres database to your new Amazon RDS MySQL database
    • heroku db:pull mysql:// 
Finished!.....well, now you can also set up the Read Replica and then set up a Master/Slave database with


I admire the valuable information you offer in your articles. I will bookmark your blog and have my friends check up here often. I am quite sure they will learn lots of new stuff here than anybody else! RegardsĀ aws jobs in hyderabad.

Post a Comment

Subscribe to Post Comments [Atom]

<< Home

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]