##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!