Home  >  Article  >  Database  >  How to migrate MySQL database in Linux system

How to migrate MySQL database in Linux system

WBOY
WBOYforward
2023-05-29 19:01:121823browse


##The first step–Perform MySQL dump

Back up the database file on the original virtual server. We need to use the mysqldump command first, and then transfer the file Transfer to new VPS.

mysqldump -u root -p --opt [database name] > [database name].sql

After performing the dump, you are ready to transfer the database.

Step 2 – Copy the database

SCP helps you copy the database. If you use the previous command, the database will be exported to the home folder.

The SCP command has the following syntax:

scp [database name].sql [username]@[servername]:path/to/database/

A sample transfer may look like this:

scp newdatabase.sql user@example.com:~/

After connecting, the database will be transferred to the new virtual private server.

Step Three: Import the Database

Once the data has been transferred to the new server, you can import the database into MySQL:

mysql -u root -p newdatabase

With that, your transfer via SCP will be complete.

By Etel Sverdlov

In this way, your transfer via SCP will be complete.

The above is the detailed content of How to migrate MySQL database in Linux system. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete