Migrating a MariaDB Database to Amazon RDS

By Bishal Dhimal | Dec 2025

📌 Table of Contents Objectives Step 1: Create an RDS Database Instance Step 2: Export Data Using mysqldump Step 3: Connect a SQL Client to RDS Step 4: Migrate Data to RDS Step 5: Configure Web Application Optional: MySQL Setup on EC2 References

Objectives

1️⃣ Step 1: Create an RDS Database Instance

In the AWS Management Console:

2️⃣ Step 2: Export Data from MariaDB Using mysqldump

On the EC2 instance hosting MariaDB:


mysqldump --databases  -u  -p > /path/to/db_backup.sql
  

Tips: Use the --single-transaction flag for InnoDB tables to avoid locking.

3️⃣ Step 3: Connect a SQL Client to RDS


# Connect using hostname
mysql -h  -u  -p

# Or
mysql --hostname  -u  -p
  

Ensure your RDS security group allows inbound traffic from your client IP.

4️⃣ Step 4: Migrate Data to RDS

Restore the database backup to RDS:


# Option 1: From within mysql client
mysql -u  -p -h 
CREATE DATABASE ;
USE ;
SOURCE /path/to/db_backup.sql;

# Option 2: Direct import from shell
mysql -u  -p -h  < 
  

Production tips:

5️⃣ Step 5: Configure Web Application

Optional: Install & Configure MySQL on EC2

Useful if you need a local test environment before migrating:


# Install MySQL
sudo apt update
sudo apt install mysql-server -y

# Secure installation
sudo mysql_secure_installation

# Create a new MySQL user
sudo mysql -u root -p
CREATE USER ''@'%' IDENTIFIED BY '';
GRANT ALL PRIVILEGES ON *.* TO ''@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;

# Configure MySQL to allow remote access
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
# Change: bind-address = 127.0.0.1 → bind-address = 0.0.0.0

# Restart MySQL service
sudo systemctl restart mysql

# Test connection locally
mysql -u  -p

# Test connection remotely (if remote access enabled)
mysql -u  -h  -p
    

References

← Back to Blogs