Home > Database > Mysql Tutorial > How to migrate MySQL database in Linux system

How to migrate MySQL database in Linux system

WBOY
Release: 2023-05-29 19:01:12
forward
1906 people have browsed it


##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
Copy after login

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/
Copy after login

A sample transfer may look like this:

scp newdatabase.sql user@example.com:~/
Copy after login

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
Copy after login

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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template