How to migrate your MySQL / MariaDB database with mysqldump, tar and scp
If you had been building the content for your new WordPress site on a Raspberry Pi 3, there will come a time when you need to migrate the underlying MySQL database to another machine, for eg. a DigitalOcean droplet, for production usage.
MySQL provides us with the mongodump client utility to produce a set of SQL statements that can be executed to reproduce the original database object definitions and table data.
A simple MySQL database migration can be performed with the following steps:
- Use mysqldump to get the set of SQL statements that can be executed to reproduce the original database object definitions and table data.
- If the mysqldump output is too big, use the
tar
command to compress it. - Use the
scp
command to send the mysqldump output from the source server to the destination server. - If you had used the
tar
command to compress the mysqldump output, use the tar command at the destination server to decompress it. - Execute the set of SQL commands in the
mysqldump
output at the destination server.
This post documents how you can migrate your MySQL / MariaDB database with utilities provided by MySQL and most Linux servers.
Follow us