How would you migrate an on-premises MySQL database to Amazon RDS with minimal downtime?
AdvancedScenarioMySQL
Answer
Short answer
Load an initial copy into RDS, keep it continuously in sync with the on-prem source using binlog replication (RDS as a replica of the external source) or AWS DMS with CDC, test the application against RDS, then do a short cutover: stop writes, wait for zero lag, repoint the app, done.
Steps
- Prepare RDS — same major version, parameter group (charset, timezone, sql_mode), security groups, Multi-AZ.
- Initial load —
mysqldump --single-transaction --source-data=2(or Percona XtraBackup → S3 → restore) to capture data plus binlog position. - Ongoing sync
- Native:
CALL mysql.rds_set_external_source(...)thenCALL mysql.rds_start_replication;(needs network path via VPN/Direct Connect). - Or AWS DMS full load + CDC.
- Native:
- Validate — row counts, checksums (pt-table-checksum or DMS validation), app smoke tests on a read-only copy.
- Cutover (minutes) — put the app in maintenance/read-only, confirm lag = 0, stop replication, point the app's connection string/DNS to RDS, resume.
- Rollback plan — keep on-prem intact (or reverse replication) until confident.
What to say in the interview
"Initial load with a consistent dump or XtraBackup, then continuous replication from on-prem into RDS via external binlog replication or DMS CDC. After validation, a short cutover — freeze writes, wait for zero lag, switch the endpoint — with on-prem kept as rollback."
More on MySQL
How do you set up MySQL and log in to it?BeginnerHow do you create a database, a table and see data in MySQL?BeginnerHow do you create a MySQL user for an application and give it permissions?BeginnerHow do you back up and restore a MySQL database?BeginnerWhat is a relational database?BeginnerWhat is the difference between a database, a table, a row and a column?Beginner