Import data

We assume that you have had MySQL shell or config MySQL command on your terminal.

Import data from on-premise database to RDS database

In this part, we create backup.sql storing data of the on-premise database and import them into the RDS database.

  • Open your terminal in the folder in which your backup file will be stored.

  • Enter this command:

    mysqldump -u username -p database_name > backup.sql
    
  • Now you will open your MobaXterm:

    • Access the EC2 instance which you created and copy its public IP. Deployment
  • Create connection by MobaXterm

    • Enter public IP of EC2 instance
    • Specify usernaem: ec2-user
    • import created key-pair Deployment
  • Upload the backup.sql file into EC2 Deployment

  • Now, we will connect to RDS database through EC2 instance:

    • Install the mysql command-line client from MariaDB.

      sudo dnf update -y
      
      sudo dnf install mariadb105
      

    The -y option installs the updates without asking for confirmation. To examine updates before installing, omit this option.

    Deployment

    Enter this command to check:

    mysql version
    
  • Connect to the RDS DB instance. Enter the following command. This action lets you connect to the RDS DB instance using the MySQL client.

    • Go to the RDS instance which you created and copy the endpoint. Deployment

    Substitute the DB instance endpoint (DNS name) for endpoint, and substitute the master username. Provide the master password that you used when prompted for a password.

    • run command:

      mysql -h endpoint -P 3306 -u username -p
      

      Deployment

  • After connecting to RDS database, we execute these command step by step to import our backup data:

    mysql> create database bistro;
    
    mysql> use bistro;
    
    mysql> source backup.sql;
    

You will see all executing query. Deployment