How To Follow The Steps To Input Data Into An RDS Database?

How To Follow The Steps To Input Data Into An RDS Database?

·

2 min read

Author: Ujwal Pachghare

To insert data into our MySQL Database which is running on Amazon RDS Instance we have to launch EC2 client.

To create and configure an Amazon EC2 client to populate your source database follow these steps

👉On the EC2Dashboard, choose Launch instance.

👉On the Launch an Instance page, enter the following values:

  1. In the Name and tags section, enter DMSClient for Name.

  2. In the Application and OS Images (Amazon Machine Image) section, leave the settings as they are.

3. In the Instance Type section, choose t2.micro.

4. In the Key pair (login) section, choose Create a new key pair or choose an existing one.

  • On the Create key pair page, enter the following:

  • Key pair name: DMSKeyPair

  • Key pair type: Leave as RSA.

  • Private key file format: Choose pem for OpenSSH on MacOS or Linux, or ppk for PuTTY on Windows.

  • Save the key file when prompted.

5. In the Network Settings section, choose Edit. Choose the following settings:

  • VPC — required: Choose the VPC with the ID that you recorded for the DB-Instances.

  • Subnet: ap-south-1a.

  • Auto-assign public IP: Choose Enable.

  • Leave the rest of the settings as they are, and choose Launch instance.

👉 we have created EC2 Client Instance in the previous step. so, now Connect to that client instance using the host name and public key that you saved in previous steps.

👉If you are using PuTTY, enable TCP keepalives on the Connection settings page so that your connection doesn’t time out from inactivity.

2. Install MySQL Client, Confirm installation as needed.

wget https://dev.mysql.com/get/mysql80-community-release-el9-3.noarch.rpm
sudo dnf install mysql80-community-release-el9-3.noarch.rpm
sudo dnf install mysql-community-server -y

3. Start the MySQL client with the following command. Provide your MySQL database endpoint.

mysql -h <RDS_Endpoint> -P 3306 -u admin -padmin123

2. Create Database and Table

CREATE DATABASE dms_db;

USE dms_db;

CREATE TABLE employees (
    id INT PRIMARY KEY,
    first_name VARCHAR(50),
    last_name VARCHAR(50),
    email VARCHAR(100),
    phone_number VARCHAR(15)
);

2. Run the following command to insert a record into the database.

INSERT INTO employees (id, first_name, last_name, email, phone_number)
VALUES (1, 'John', 'Doe', 'john.doe@example.com', '123-456-7890');

INSERT INTO employees (id, first_name, last_name, email, phone_number)
VALUES (2, 'Jane', 'Doe', 'jane.doe@example.com', '098-765-4321');

INSERT INTO employees (id, first_name, last_name, email, phone_number)
VALUES (3, 'Jim', 'Brown', 'jim.brown@example.com', '111-222-3333');

INSERT INTO employees (id, first_name, last_name, email, phone_number)
VALUES (4, 'Jill', 'Smith', 'jill.smith@example.com', '444-555-6666');

3. Run this command to see entry

select * from employees;

Did you find this article valuable?

Support AutOps by becoming a sponsor. Any amount is appreciated!