Couple of days ago I saw a few amateur developers struggling to importing an .sql file to Remote Database Server in AWS. They were migrating to Amazon Web services from a self hosted server. The database they exported form the old server sized around 125 MB and was too heavy to be uploaded as a whole.
They did get a PhpMyadmin running on a EC2 instance and get it connected to RDS, but the apache limit was a stopper here. An editable value but the Internet connection was not stable due to a scheduled maintenance work of ISP so pushing 100+Mb of a single file was not an option.
I had a few mins to talk with them and joined to solve the issue. I have no idea why one of them showed me a git repo hosted on Bit bucket which had the .sql file online I didn’t know how they managed to get it uploaded but it was available.
I cloned the repo to the EC2 and connected to the RDS via after SSH’ing to the server and imported the .sql via terminal. If you happen to be in same situation here is what you can do from start of exporting data from current server to Importing to RDS.
- Export Data from MySQL server as .sql file.
- Set up your RDS instance and an EC2 Instance to import the data. You can use any EC2 with MySQL installed. Make sure to allow the EC2 with permissions to connect to RDS.
- SSH connect to the EC2.
- Get the exported file onto the EC2. You can use git remote repository to upload and clone it or use FTP.
- Now CD to the directory where the .sql exist on EC2.
- Connect to your MySQL server in RDS.
$ mysql -h
-port=3306 -u -p
- Create and Select the database where you want the data to be imported.
$ mysql> create database
; $ mysql> use
- Here comes the magic,
$ mysql> source
- You have your Database on RDS.
Remote connection can also be done from your local machine if you have a strong Internet connection.