Very often I need to restore MySQL dump on AWS RDS. The best way to do it is to use Bastion host to optimize internet traffic.
Main goal is to upload gzip archive to Bastion host, forward MySQL port to RDS and restore dump.
Copy backup to Bastion host
Get Bastion IP from AWS console.
Copy backup with SCP:
$ scp -r -i <key pair>.pem backup.sql.gz ec2-user@<Bastion IP>:/tmp/backup.sql.gz
Connect to Bastion Host
Connect to your Bastion host and install the latest updates and the MySQL client tools using the following commands:
$ sudo yum update -y $ sudo yum install mysql -y
Decompress SQL dump
$ gzip backup.sql.gz -d
Import MySQL dump
Connect to your Amazon RDS DB instance as a remote host from your Bastion host using the mysql command.
$ mysql -h <rds_host_name> -P 3306 -u <db_master_user> -p --default-character-set=utf8
> use your_database; > SET names 'utf8'; > source /tmp/backup.sql;