When backing up a database, if the database size is small, there is no problem in using the phpMyadmin tool to directly back it up. Similarly, if the data size is small, it is OK to directly import it. However, if the database is large, it is not easy to do so, which will lead to incomplete backup and recovery. Then we still need to learn how to back up large databases.
Here, Lao Zuo simply records the commonly used methods of MySQL database backup, recovery and restore, not to mention that these commands are incomprehensible or impossible. If you want to have such a large database, you must learn them, otherwise you can't really mix them.
First, command to back up the database
1. Backup single site database
If we backup a single website database, we can use the method of specifying the database name.
mysqldump -u Database user name -p Database password Database name > database_name.sql
2. Multiple database backups
mysqldump –databases database_onedatabase_two > two_databases.sql
In the above code, database_one is the name of the first database to be backed up, and database_two is the name of the second database.
3. Backup all databases
mysqldump --all-databases > all_databases.sql
Second, restore the database
Mysql - u database user name - p database password database name<database file name.sql
We need to restore a database accordingly.
Extended reading of MySQL database backup information:
1、 Solve the problem of "when using LOCK TABLES" when mysqldump backs up the database
2、 Explain how to use the mysqldump command to backup and restore MySQL data
3、 The prompt "should be repaired when using LOCK TABLES" for MySQL database backup is solved
4、 Ideas on website files and MySQL database backup process for newcomers
Scan the code to follow the official account
Get more news about webmaster circle!
Entrepreneurship, operation and new knowledge