π AWS Database Migration Service: Migrating Databases from EC2 to AWS RDS Using DMS (Manual Process)
![]() EC2 to RDS Migration Using AWS DMS - Architecture Diagram |
![]() EC2 to RDS Database Migration - DMS Manual Workflow |
![]() Database Migration Overview: EC2 β RDS via DMS |
- Go to EC2 Console β Click on "Launch Instance"
- Name and Tags
- Name:
database-source-ec2
- Name:
- Application and OS Images (AMI)
- Select:
Amazon Linux 2 AMI (HVM) β Kernel 5.10, SSD Volume Type
- Select:
- Instance Type
- Choose:
t2.micro (Free Tier eligible)
- Choose:
- Key Pair (Login)
- Choose your key pair:
my-key-pair
- Choose your key pair:
- Network Settings
- Select Allow all traffic (Security Group)
- Or manually Add Inbound Rule:
- Type: MySQL/Aurora
- Protocol: TCP
- Port Range: 3306
- Source: Your IP (or specific IP range)
- Configure Storage
- Leave default (8 GiB General Purpose SSD)
- Launch Instance
- Go to the Instances page in the EC2 dashboard
- Select the database-source-ec2 instance
- Click Connect β Choose EC2 Instance Connect (Browser-based SSH) or your preferred method (e.g., SSH with .pem key)
-
Update the Package Index
sudo su - sudo yum update -y
-
Download MySQL 8.0 Community Release Package
wget https://repo.mysql.com/mysql80-community-release-el7-5.noarch.rpm
-
Install MySQL Repository and Import GPG Keys
sudo yum install mysql80-community-release-el7-5.noarch.rpm -y sudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2023 sudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql sudo yum makecache
-
Install MySQL Server
sudo yum install mysql-community-server -y
-
Verify Installation
mysql -V
-
Start and Enable MySQL
sudo systemctl start mysqld sudo systemctl enable mysqld systemctl status mysqld
-
Retrieve Temporary Root Password
sudo grep 'password' /var/log/mysqld.log
-
Login to MySQL Using the Temporary Password
sudo mysql -u root -p
π Enter the temporary password from Step 7
-
Change the Root Password
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Admin@123'; SHOW DATABASES;
-
Exit and Re-login with the New Password
sudo mysql -u root -p
Enter Admin@123 when prompted.
- Create a New Database and Table
CREATE DATABASE vsv;
USE vsv;
CREATE TABLE customers (
id INT PRIMARY KEY AUTO_INCREMENT,
customer_id VARCHAR(255),
first_name VARCHAR(100),
last_name VARCHAR(100),
company VARCHAR(255),
city VARCHAR(255)
);
- Insert Sample Records
INSERT INTO customers (customer_id, first_name, last_name, company, city) VALUES
('DD37Cf93aecA6Dc', 'Sheryl', 'Baxter', 'Rasmussen Group', 'East Leonard'),
('1Ef7b82A4CAAD10', 'Preston', 'Lozano', 'Vega-Gentry', 'East Jimmychester'),
('6F94879bDAfE5a6', 'Roy', 'Berry', 'Murillo-Perry', 'Isabelborough'),
('5Cef8BFA16c5e3c', 'Linda', 'Olsen', 'Dominguez, Mcmillan and Donovan', 'Bensonview'),
('053d585Ab6b3159', 'Joanna', 'Bender', 'Martin, Lang and Andrade', 'West Priscilla'),
('2d08FB17EE273F4', 'Aimee', 'Downs', 'Steele Group', 'Chavezborough');
- Verify Data
SELECT * FROM vsv.customers;
14 User Table SQL Script
CREATE TABLE user (
id INT PRIMARY KEY AUTO_INCREMENT,
customer_id VARCHAR(255),
first_name VARCHAR(100),
last_name VARCHAR(100),
company VARCHAR(255),
city VARCHAR(255)
);
- how All Tables
SHOW TABLES;
- Insert Sample Data
These records assume the table has already been expanded with additional fields like
phone
, etc. If not, you should alter the table accordingly.
INSERT INTO user (customer_id, first_name, last_name, company, city) VALUES
('CUST1001', 'John', 'Doe', 'TechCorp', 'New York'),
('CUST1002', 'Jane', 'Smith', 'InnovateX', 'San Francisco'),
('CUST1003', 'Aidan', 'Brown', 'GlobalTech', 'Los Angeles');
- Query the Table
SELECT * FROM vsv.user;
- Check Existing Users
SELECT user, host FROM mysql.user WHERE user = 'root';
- Create Root User for Any Host (if not exists)
CREATE USER 'root'@'%' IDENTIFIED BY 'Admin@123';
- Grant All Privileges to Root
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
- Apply Changes
FLUSH PRIVILEGES;
- Optional - Reconfirm Root Password for '%'
ALTER USER 'root'@'%' IDENTIFIED BY 'Admin@123';
FLUSH PRIVILEGES;
- Go to the AWS Console.
- In the Search Bar, type RDS and select it from the dropdown.
- In the left-side menu of the RDS Dashboard, click Databases.
- Click Create Database.
- Choose Standard Create.
- Engine type: MySQL
- Version: MySQL 8.4.3
- Templates: Free tier
- DB Instance Identifier:
my-sqlserver-db
- Master Username:
admin
- Password Management: Self-managed
- Master Password:
Yaswanth123reddy
- Confirm Password:
Yaswanth123reddy
- DB Instance Class:
db.t3.micro
- Storage: 20 GiB
- Compute Resources: Donβt connect to EC2
- Network Type: IPv4
- VPC: Default (
vpc-0b08fcea62cde9567
) - DB Subnet Group: Default
- Public Access: yes
- VPC Security Group: Choose existing β Select default
Click Create Database
- Go back to RDS β Databases.
- Click on your DB instance:
my-sqlserver-db
. - Scroll down to Connectivity & Security.
- Copy the Endpoint.
π Example:
my-sqlserver-dbc0n8k0a0swtz.us-east-1.rds.amazonaws.com
Connect to RDS via MySQL Workbench
- Open MySQL Workbench
- Go to Database > Manage Connections
- Fill in:
- Connection Name:
AWS MySQL
- Hostname:
<RDS endpoint>
ex:my-sqlserver-dbc0n8k0a0swtz.us-east-1.rds.amazonaws.com
- Port:
3306
- Username:
admin
- Password:
Yaswanth123reddy
- Connection Name:
- Click Test Connection
- β If successful: βConnection parameters are correct.β
- If successful β Click OK
- In AWS Console, search for Database Migration Service and open it.
- On the left menu, click Replication instances.
- Click Create replication instance.
- Open a new tab β Go to IAM β Roles β Click Create Role
IAM Role Configuration:
- Trusted entity type: AWS Service
- Use case: Select DMS
- Permissions: Administrator Access
- Role Name:
dms-cloudwatch-log-role
- Click Create Role
- Name: ec2-rds
- Instance class:
dms.t3.medium
- Engine version: 3.5.2
- High Availability: Dev or test workload (Single-AZ)
- Storage: 50 GiB
- Network Type: IPv4
- VPC: Default VPC
- Replication Subnet Group: default
- Publicly Accessible: β Yes
Click Create replication instance
β Step 2: Create Endpoints (Source Endpoint) (source endpoint we have to give the ec2 instance information)
#### πΈ 2.1 Go to DMS β Endpoints β Click Create Endpoint
#### πΉ SOURCE Endpoint (EC2 MySQL Database)
- Go to IAM β Create Role
- Trusted entity: AWS Service
- Use case: DMS
- Permissions: AdministratorAccess
- Role Name:
dms-cloudwatch-log-role
- Click Create Role
- Endpoint type: Source
- Endpoint identifier:
source-from-ec2-db
//any name - Source engine: MySQL
- Access method: Provide access information manually
Fill in:
Copy EC2 DNS:
- Go to your EC2 instance (source Ec2-rds instance ) open --> Copy Public IPv4 DNS
- Server name: Paste source Ec2-rds instance Public IPv4 DNS (eg: ec2-18-234-236-228.compute-1.amazonaws.com)
- Port: 3306
- Username: root
- Password:
Admin@123
- Scroll down and click Run Test
- β If successful, EC2 database is connected properly
- Click Create endpoint
- Endpoint type: Target Endpoint
- β Select RDS DB instance
- Select RDS DB instance: Select
my-sqlserver-db
- Endpoint identifier:
target-rds
// give any name - Target engine: MySQL
- Access method: Provide access information manually
- Server name: (auto-filled RDS Endpoint)
- Port: 3306
- Username: admin
- Password:
Yaswanth123reddy
- Select Replication Instance:
ec2-rds
- Click Run test
- β If successful, click Create endpoint
π Note: At this point, you should have two endpoints:
source-form-ec2-db
(from EC2)target-rds
(to RDS)
- Task identifier:
migration-form-ec2-db-to-rds
- Replication instance:
ec2-rds
- Source database endpoint:
source-form-ec2-db
- Target database endpoint:
target-rds
- Migration type: Migrate existing data and replicate ongoing changes
- How long to replicate: Indefinitely
- Editing mode: Wizard
- Custom CDC stop mode: Disable
- Target table preparation mode: Do nothing
- Stop task after full load completes: Don't stop
- LOB columns: Don't include
- Data validation: Turn off
- Click on Selection rules β Add new selection rule:
- Schema:
vsv
[(vsv is my datadase name) or give % it wii take all datadase] - Table name:
customers
(enteryour table name here [i am create customers table vsv database] or give % it wii take all table) - Action: Include
- Schema:
- Pre-migration assessment: β Deselect it
- Task startup configuration: Automatically on create
Click Create database migration task
Once the task runs, DMS will:
- Load existing records from EC2 MySQL (
vsv.customers
) to RDS - Start capturing ongoing changes (CDC)
- Open MySQL Workbench
- Go to Database > Manage Connections
- Fill in:
- Connection Name:
AWS MySQL
- Hostname:
<RDS endpoint>
ex:my-sqlserver-dbc0n8k0a0swtz.us-east-1.rds.amazonaws.com
- Port:
3306
- Username:
admin
- Password:
Yaswanth123reddy
- Connection Name:
- Click Test Connection
- β If successful: βConnection parameters are correct.β
- If successful β Click OK
CREATE DATABASE vsv;
USE vsv;
SHOW TABLES;
Click β‘ to execute and verify your tables and data.
INSERT INTO customers (customer_id, first_name, last_name, company, city) VALUES
('CUST001', 'John', 'Doe', 'Acme Corp', 'New York'),
('CUST002', 'Jane', 'Smith', 'Global Tech', 'San Francisco');
INSERT INTO `user` (customer_id, first_name, last_name, company, city) VALUES
('USR001', 'Alice', 'Brown', 'TechSphere', 'Austin'),
('USR002', 'Brian', 'Taylor', 'DevSolutions', 'Denver');
SELECT * FROM customers;
SELECT * FROM `user`;
CREATE DATABASE vsv;
USE vsv;
SHOW TABLES;
Click β‘ to execute and verify your tables and data.