"How do I migrate MySQL from one physical server to another? For example, I have a MySQL server using InnoDB tables, approximately 20GB in size. What is the most efficient way to move it to a new server?"

MySQL is a relational database management system based on Structured Query Language. It's used to manage information stored on computers, whether it's personal data or vast amounts of company info. Thanks to this free database management system, businesses can easily scale their operations. So, how do you migrate a database between two servers to keep that data safe?

Follow our step-by-step guide to move your MySQL database to another server using a third-party database transfer tool and MySQL's built-in backup program. Both methods work for migrating a database in Windows.

mysql logo (Image: MySQL logo)

Related Articles

How to Migrate MySQL Database to SQL Server | Step-by-Step Guide

This article offers three methods to convert MySQL to SQL Server, including using Server Migration Software and SQL Server Migration Assistant tools. Keep reading to learn more solutions for migrating a MySQL database to SQL Server.

Migrate SQL

[(Easiest) How to move a MySQL database from one server to another](#1)

No need to learn the command lines mentioned in other articles, you can move MySQL database with just a few clicks. This is why the Todo PCTrans tool stands out among many tools. All you need to do is download this database migration tool and execute 3 simple steps. Trust our tool! We specialize in transferring database from one server to another.

  24/7 Technical Support

Free Consultation

Tip:

By default, Tools Todo PCTrans supports migration of MySQL installed on the system disk. It also helps transfer custom-installed MySQL.

Step 1: Launch the Todo PCTrans tool on both the source and target computers. On the source computer, select “This is my old PC” and click “Next.”

Select a location, then click “Scan.”

Step 2: Connect to the target new server computer with a password or an authentication code.

Connect two PCs

Step 3. The tool will scan the content on your source server. When it's done, under Applications, select the MySQL app you want to transfer, then click Migrate.

Select the MySQL to transfer

Step 4. Wait for the MySQL transfer to complete, and then click OK to finish the operation.

Finish MySQL migration

  24/7 Technical Support

Free Consultation

Video tutorial on migrating a MySQL database to another server

This is an HTML code for embedding a YouTube video. On a webpage, it will display a video player with a height of 450 pixels and a width of 700 pixels, allowing fullscreen, clipboard writing, encrypted media, gyroscope, and picture-in-picture features. The video ID is "L_CiL780Lgo".

For remote transfers, you can try using the Todo PCTrans tool in "Backup and Restore" mode. In the next section, we'll look at a database backup program that saves your databases to individual files using mysqldump.

How to Migrate a Database to a Target Server

To migrate a database between two servers, you would use Mysqldump, a command-line tool that creates backups of MySQL databases, thereby cloning them.

First, you need to export the database to a Dump file, then transfer it to the target server. Finally, import the MySQL database on the new server.

Step 1: Export the MySQL database to a dump file

Log in to your old server and use systemctl to stop the MySQL service:

Stop the MySQL service:

Use the `mysqldump` command to export the database as a dump file:

Export all MySQL databases: mysqldump -u [username] -p --all-databases > all_databases.sql

Export a single database: mysqldump -u root -p --opt [database_name] > database_name.sql

Step 2: Use the SCP command to transfer the MySQL database to the new server

SCP is a file transfer program that comes pre-installed on Linux systems. To use it, you'll need to enter an SCP command in the terminal. If that doesn't work, you'll need to download SCP first. Alternatively, you can go back and use Todo PCTrans.

Backup all databases: ```shell scp all_databases.sql user@example.com:~/ ``` This command will copy the 'all_databases.sql' file to the home directory of the user 'user' on the server with the domain 'example.com'. Please replace 'user@example.com' with the actual server username and domain/IP and make sure the 'all_databases.sql' file exists in your local directory before running the command.

Single database: scp database_name.sql username@example.com:~/

When it's done, you should see your database on the new server.

Step 3: Import the database into MySQL

Please run the following command line to import the MySQL database dump file into the new server:

All databases: mysqldump -u [username] -p --all-databases > all_databases.sql

Single Database: mysql -u [username] -p new_database < database_name.sql

More options:

To move a specific table within a MySQL database, use this command:

This command is used to export user and table data from a specified MySQL database into an SQL file named dump.sql. Here, [username] is your MySQL username, [database] is the name of the database you want to backup, and [table1] and [table2] are the names of the tables you want to export. When running this command, you will be prompted to enter the corresponding password.

For more information on transferring SQL databases using Todo PCTrans, please click the button below to consult.

Please provide the English content you would like translated, and I will do my best to translate it into Chinese.

Todo PCTrans Enterprise Tool

Bulk PC program migration, Windows account migration, domain account migration, virtual-to-physical machine migration, and local to cloud desktop migration.

24/7 Technical Support Chat