MySQL uses commands to back up and restore databases. mysql commands
When a database is used, database backup is performed. When a database fails to be started due to a serious error or data loss, data can be restored in a timely and effective manner. This article briefly introduces how to back up and restore a MySQL database.
Back up database
Back up a database using the mysqldump command
Copy codeThe Code is as follows:
# If you want to back up the game database:
Mysqldump-u root-p game> game_backup. SQL
# If you want to back up all databases:
Mysqldump-u root-p -- all-databases> all_backup. SQL
Restore database
1. Use the mysql command to restore the database
Restore game_backup. SQL to the game Database:
Copy codeThe Code is as follows:
Mysql-u root-p game <game_backup. SQL
2. Use the source command to restore the database
If the database is too large, we recommend that you use the source command.
Copy codeThe Code is as follows:
Mysql> source game_backup. SQL