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 both the export and import operations are
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.