# On-Premise MySQL Migration to Amazon RDS (MySQL) using AWS DMS

Migrating your on-premises MySQL database to **Amazon RDS for MySQL** with **AWS Database Migration Service (DMS)** is a common way to move to a managed, highly available database while keeping zero downtime or minimal. In this blog, I’ll show how you can migrate your databases to the AWS Managed Database.

## **Architecture:**

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1758025218331/b70c0c41-afcb-448f-9154-7420a872f62b.png align="center")

## Assumptions & prerequisites

1. Network connectivity between AWS and on-prem (VPN / Public IP available).
    
2. Administrative access to source MySQL and to the AWS account (permissions to create RDS, DMS, IAM, roles, subnets, and security groups).
    

### **Step-by-step migration procedure:**

### Step 1: Assess & plan

Decide migration type: **Full load + ongoing replication (CDC)** is recommended for production to reduce downtime.

* Configure MySQL for DMS (Binary Logs + Remote Access)
    

Edit the MySQL configuration file **(/etc/mysql/mysql.conf.d/mysqld.cnf** on Ubuntu/Debian, or **/etc/my.cnf** on RHEL/CentOS/Amazon Linux).

```plaintext
bind-address = 0.0.0.0 
# AWS DMS timeout configuration
net_read_timeout=300
net_write_timeout=300
wait_timeout=300
```

Save and restart MySQL:

```bash
 sudo systemctl restart mysql
```

### Step 2: Create a dedicated DMS user and grant privileges

```bash
CREATE USER 'dms_user'@'%' IDENTIFIED BY 'StrongPassword!';
GRANT REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'dms_user'@'%';
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, INDEX ON `abi_db`.* TO 'dms_user'@'%';
GRANT ALL PRIVILEGES ON awsdms_control.* TO 'dms_user'@'%';
FLUSH PRIVILEGES;
```

### Step 3: Create IAM Roles for AWS DMS

Create the following roles in IAM → Roles → Create role → AWS Service → DMS and attach the matching AWS managed policies:

* **dms-cloudwatch-logs-role** → attach AmazonDMSCloudWatchLogsRole
    
* **dms-vpc-role** → attach AmazonDMSVPCManagementRole
    
* **DMSS3AccessRole-maxdms-migration-bucket** → attach AmazonS3FullAccess (or custom bucket policy for least privilege)
    

**NOTE:** All roles must trust dms.amazonaws.com

### Step 4: Create the target: Amazon RDS for MySQL

* In the AWS Console → RDS → Create database. Choose **MySQL**, pick engine version compatible with your application
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1760418245607/738129b8-8b1b-4d39-984d-6c1ec4c9c63c.png align="center")
    
* Choose instance class, storage, Multi-AZ (recommended for production), and set backups & maintenance.
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1760418357074/f974e9d7-a816-43a0-b9ad-2ab2da471756.png align="center")

* Create or use a DB subnet group inside the VPC where your DMS replication instance will run.
    
* Note the RDS endpoint, username, and password — you’ll use these for the DMS target endpoint.
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1760418703362/c12ac378-9020-42c0-bf28-5361193d2fe1.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1760419033571/241d30c9-61f8-4d66-b0c4-e77a6d319b36.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1760419058900/7f7c8aea-ba7d-481f-99ad-b1ea67589612.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1760419083372/8efae5f3-e741-4f46-89df-335a83611f07.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1760419105179/b5acc5c2-9a5d-4e23-8e2c-be8615996427.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1760419137369/19cf6175-dcc1-4bde-ac38-df42de3c72cf.png align="center")

### Step 5: Networking: ensure connectivity

Decide how DMS will reach on-prem:

* **Recommended (secure):** AWS VPN / Direct Connect.
    
* **Alternative:** Open source MySQL port from DMS replication instance public IP range (less secure).  
    Make sure:
    
* Security groups for RDS allow inbound from the replication instance.
    
* On-prem firewall allows inbound from replication instance or through your VPN.
    
* If using public endpoints, consider enabling SSL for MySQL connections
    

### Step 6: Create an AWS DMS replication instance

* Search for <mark>AWS DMS</mark> in the management console, select <mark>Replication instances</mark> and click on <mark>Create replication instance</mark>.
    
* Choose instance class and storage. For large databases or heavy throughput pick a larger instance.
    
* Place the instance in the same **VPC** and subnets that can reach both on-prem (via VPN) and the RDS target.
    
* Wait for the instance to become **available**.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1760419202582/8b972395-fc5f-4a43-b5b1-63abd1736170.png align="center")
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1760419224935/50b595cf-a82f-4265-85c0-fa1c55fcd6f1.png align="center")
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1760419268004/ce74f23f-2523-4326-9a3c-8ed196841bfd.png align="center")
    

### Step 7: Create source & target endpoints in DMS

**Source endpoint (MySQL)**:

* Engine: MySQL.
    
* Hostname: your on-prem IP or hostname reachable by the replication instance.
    
* Port: 3306 (or custom).
    
* Username/password: the `dms_user` you created.
    
* Test the endpoint connection from the replication instance (there’s a “Test endpoint connection” button).
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1762063013026/20d76380-50e5-40b3-85ce-93fdef40a7c3.png align="center")
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1762063133341/9cdfd354-40d4-49b2-a652-08c8ad63fdf2.png align="center")
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1760419447740/1a9dac62-e88a-4600-b15d-922bbe29cd19.png align="center")

Similarly,

**Target endpoint (RDS MySQL)**:

* Engine: MySQL.
    
* Hostname: RDS endpoint.
    
* Port: 3306.
    
* Username/password: RDS master user (or another user with sufficient privileges).
    
* Test the endpoint.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1760419610698/d93aa560-ce16-420a-b087-1b993bb6ddb4.png align="center")
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1760419649303/5600b0e2-ab31-438b-a21a-cb20fa1417cd.png align="center")
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1760419688656/01af8c72-03ef-4644-a1c9-36f2be84ebf0.png align="center")
    

If the endpoint tests fail, check security group rules, network ACLs, and firewall rules.

### Step 8: Create and configure the migration task

* Search for <mark>DMS</mark> in the console, Select <mark>Database migration tasks</mark> and click on <mark>Create task</mark>.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1760419772145/9cf21617-77ce-4563-8594-0137bf6d0191.png align="center")
    

Choose:

* **Replication instance**
    
* **Source endpoint**
    
* **Target endpoint**
    
* **Migration type**: *Migrate existing data and replicate ongoing changes* (Full load + CDC).
    

* **Table mappings**: choose to migrate entire schemas or select tables. You can use JSON mapping to include/exclude objects.
    

**Task settings**:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1760419825870/9a7a7d6f-b1e6-425e-b28e-28cf32b1a433.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1760419863680/70d3e54a-0f42-4947-9f1b-2803e313c306.png align="center")

* Choose how to handle target table prep (e.g., *Do nothing* or *Drop tables and recreate*).
    
* For large LOBs, select appropriate LOB mode (e.g., Full LOB mode).
    
* Tune commit rate and parallel load options if needed.
    

Start the task (choose *Start task on create* or start after creation).

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1760419915867/903c8562-5130-40b3-a7aa-5436f32a767c.png align="center")

### Step 9: Monitor the migration

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1760420094049/057590ea-8a4b-4c15-9fe5-27fb30595da6.png align="center")

In DMS Console:

* Watch task status and replication instance CPU, memory, and disk I/O.
    
* Check **Table statistics** for rows loaded per table
    

## Conclusion

Using AWS DMS to migrate on-prem MySQL to Amazon RDS lets you move with minimal downtime when planned and executed carefully.
