Created
April 29, 2014 01:23
-
-
Save aruseni/11388609 to your computer and use it in GitHub Desktop.
Transfer local MySQL databases to Amazon RDS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
DATABASES="cooldb nicedb epicdb" | |
LOCAL_PWD="Tr0ub4dor&3" | |
RDS_PWD="correcthorsebatterystaple" | |
RDS_HOST="blahblahblah.rds.amazonaws.com" | |
for DB in $DATABASES ; do | |
echo "Moving $DB" | |
echo "create database $DB;" | mysql --host=$RDS_HOST --user=root --password=$RDS_PWD | |
echo "Creating schema" | |
mysqldump --routines -d --user=root --password=$LOCAL_PWD $DB | perl -pe 's/\sDEFINER=`[^`]+`@`[^`]+`//' | mysql --host=$RDS_HOST --user=root --password=$RDS_PWD $DB | |
echo "Transferring data" | |
mysqldump --verbose --no-create-info --skip-triggers --no-create-db -q --user=root --password=$LOCAL_PWD $DB | mysql --host=$RDS_HOST --user=root --password=$RDS_PWD $DB | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment