Migrating a WordPress database between servers

wordpressdatabasemysqlmigrationops

Database migrations should be predictable and reversible.

Prerequisites

High-risk warning

If the source site is “live-ish” (traffic, writes), use a consistent export strategy.

Export

InnoDB consistency (live-ish sites):

mysqldump --single-transaction -u <db_user> -p <database_name> > backup.sql

Transfer

Use scp (or your cloud provider’s secure transfer):

scp backup.sql <dest_user>@<dbhost1>:/tmp/backup.sql

Import

mysql -u <db_user> -p <database_name> < /tmp/backup.sql

Verify

Notes