Migrate mysql database between servers
Dec 28, 2025
First of all, make sure you have mysql command available. If not install the mysql client package using the command
After the mysql command is available, then we will make a database dump from old server, transfer the dump to new server and then import the dump to the new server.
Create database dump from old server
This command might take a long time to finish based on the size of your database. Wait for it to complete. Else, the dump file will be corrupted and unusable. After the process is complete, it will create a file on the current directory when the command was executed.
Transfer the dump file
Copy the dump file to the new server. You can use scp, sftp or any other mechanisms to transfer the files.
