Regarding this VPS beginner tutorial , I have also written a series one after another. The previous ones have numbers, but I really don’t know how to type out the two-digit good VPS in this circle! Confused, the simple usage things I thought of later are still titled "VPS Beginner Tutorial", but they are not numbered.
In this article, we take the LNMP environment as an example. When it comes to exporting and importing MySQL databases, everyone will definitely think of using phpMyAdmin at the first time. Yes, phpMyAdmin is very convenient, but when the database itself is relatively large, for example, there are several 100M, so it would be a bit sad to upload and import it locally. Therefore, today we will share how to export and import the MySQL database after directly logging into the VPS via SSH.
Because export and import are very simple, just one line of commands.
First, log in to the VPS via SSH and export the database. The command format is:

/usr/local/mysql/bin/mysqldump –u (username) –p (password) (database name) > /home/wwwroot/zr.sql

I would like to add to the above line of command, -u is followed by a space, and then the database user name. There is no space after -p, directly followed by the database password, then a space, the database name, and then a space, and the following content. zr.sql is a name you define yourself.
Importing on other VPS is also very simple. The command format is:

/usr/local/mysql/bin/mysql –u (user name) –p (password) (database name) < /home/wwwroot/zr.sql

The format and spaces are exactly the same as above.
I also executed these commands on the VPS, a picture to illustrate.
mysql
In the picture above, I have a database on the VPS, the name is zr, the user of this database is also zr, and the password is 12345678.
In fact, if it is an LNMP environment, there is another way to directly copy the folder /usr/local/mysql/var/(database name) to the new VPS. This method can also be used. Rescued many databases experiencing problems.


Hong Kong/United States/Domestic High Speed ​​VPS

postid
2149

Leave a Reply