MySQL data backup and recovery we can use MYQL's own tools mysqldump, MySQL to achieve.
MYSQLDUMP supports remote single table backups, single database backups, and all database backups.
= = Backup = =
Note the space, additional parameters please add yourself. If-h-u-p, remote backup needs to specify-H server address
-E indicates export SQL is 20 times times faster than normal inserts for bulk inserts
-H Server Host address
-U Account
-P account password
Single-table backup (back up a table)
The code is as follows |
Copy Code |
MYSQLDUMP-E-u xxx-pxxx database name Table name > save location
|
Single-database backup (backs up all tables in the specified library)
The code is as follows |
Copy Code |
MySQL dump-e-u xxx-pxxx database name > Save location |
All database backups (back up all databases)
The code is as follows |
Copy Code |
MYSQLDUMP-E-u xxx-pxxx--all--database > Save location |
= = Restore = =
Note the space, additional parameters please add yourself. If-u-p, remote backup needs to be specified:-H server address
Method One:
The code is as follows |
Copy Code |
Mysql-u Root Database name < location of backup files |
Method Two:
You can also use MySQL login to enter the MySQL Shell to execute the following command
Use database name (toggle database)
Source Backup file location (Execute SQL script)
Note: If you do not have a statement in the backup file that drops create database, you will need to manually delete the database after the restore and then create an empty library.