Question · Digital Marketing & SEO

Best practices for migrating a large MySQL database with millions of rows

24 Feb 2026
I need to migrate a production MySQL 8.0 database to a new cloud server. The main table has over 5 million rows and I need to minimize downtime. I've used mysqldump for smaller databases, but I'm concerned about the import time causing too much downtime on a dataset this size. What are the best methods for a fast and reliable migration? I've heard about using
mysqldump --single-transaction
or tools like Percona XtraBackup, but I'm not sure which is best for my scenario.
Best answer
For a large MySQL database migration with minimal downtime, Percona XtraBackup is the superior choice over mysqldump. While mysqldump with `--single-transaction` provides a logical backup suitable for smaller databases, its single-threaded nature means importing 5 million rows will be prohibitively slow, extending your downtime window significantly. XtraBackup performs physical backups by copying data files directly, which is far faster and allows for incremental backups to reduce transfer time. The core concept here is leveraging a physical backup tool that operates at the file system level for speed, combined with binary log positioning for near-zero downtime.

Key steps involve taking a full backup on the source server, transferring it to the destination, preparing it for consistency, and then configuring replication to catch up any changes that occurred during the transfer. Finally, you promote the new server and repoint your application.


# On source server (take backup)
xtrabackup --backup --target-dir=/path/to/backup
xtrabackup --prepare --target-dir=/path/to/backup

# Transfer backup to new server
rsync -avrP /path/to/backup/ new-server:/path/to/backup/

# On new server (prepare and restore)
xtrabackup --copy-back --target-dir=/path/to/backup
chown -R mysql:mysql /var/lib/mysql

# Start MySQL on new server and setup replication
24 Feb 2026
Your answer Sign in or register to reply

This is a public discussion. Create a free account to answer. Takes 20 seconds. No email gates.

Who Is Online

In total there are 90 users online: 0 registered, 83 guests and 7 bots.

Most users ever online was 5,555 on 17 Jul 2026, 3:23 am.

Bots: AhrefsBot Applebot Baiduspider Bingbot Other Bot PetalBot SemrushBot

Users active in the past 15 minutes. Total registered members: 369