In this article, we take the LNMP environment as an example. If you export and import data to the MySQL database, you must first think of using phpMyAdmin. Yes, phpMyAdmin is very convenient, but when the database itself is relatively large, for example, there are hundreds of megabytes, so it is a bit sad to get the local upload and import. So today we will share with you how to export and import MySQL Databases after logging on to VPS through SSH.
Because the export and import operations are very simple, they are just a line of commands.
First, log on to the VPS through SSH and export the database. Command Format:
/Usr/local/mysql/bin/mysqldump-u (username)-p (password) (Database Name)>/home/wwwroot/zr. SQL
I would like to add a description of the above line of commands.-u is followed by a space, followed by the database username, and-p is followed by no space. connect directly to the database password, and then enter a space, Database Name, space, followed by the following content, where zr. SQL is your own name.
Importing on other VPS is also very simple. Command Format:
/Usr/local/mysql/bin/mysql-u (User Name)-p (password) (Database Name)
The format is the same as that of spaces.
I also run these commands on VPS, as shown in a figure.
In, I have a database on VPS, whose name is zr. The user of this database is zr, And the password is 12345678.
In fact, if they are all LNMP environments, there is another way to copy the/usr/local/mysql/var/(Database Name) folder to the new VPS, this solution can also save a lot of problematic databases.