MySQL backup and recovery detail

A, MySQL full backup and recovery

The main purpose of disaster recovery backup, the backup application can also test the rollback data modification, query historical data, and auditing.

The importance of data backup 1

The value of business-critical data, data protection of the normal operation of their business. Therefore, the reliability of data security and operation and maintenance of data is a top priority, any loss of data are likely to have serious consequences for the company. Cause of data loss is usually summarized as follows:

Program error
human error
calculation error
disk failure
disaster (fire, earthquake) and theft
Third, the common backup methods

Second, the database backup type

1, physical and logical point of view:

Backup database backup can be divided into physical and logical backup. Physical backup of the database is the physical files of the operating system (such as data files, log files, etc.) of backup. This type of backup is important for large databases in case of problems need quick recovery.

Can be divided into physical backup cold backup (offline backup), hot backup (online backup) and warm backup.

  • Cold backup: the database backup operation in the closed state;
  • Hot backup: when the database backup operation is running, the method relies on the backup database log file;

  • Locking the database backup table (not writable, but can be read) state;: Temperature backup

Logical database backup is a backup of logical components (e.g., database objects such as tables) is expressed as a logical structure of the database (create database, create table statement) and content (insert statement or delimited text file). This type of backup can be used to edit a data value or a smaller amount of data table structure, or re-create the data on a different machine architectures.

2, from the perspective of the database backup strategy:

From the point of view of the database backup strategy, backup of the database can be divided into full backup, differential backup and incremental backup. Which it does, is to achieve a complete backup of the differences, the basis of incremental backups.

  • Full backup: every time a complete backup of the data, namely backup of the entire database. Backup and restore operation is very simple, but there are a lot of duplicate data, will take up a lot of disk space and backup time is very long.

  • Differential backup: backup that since the last full backup of all files that have been modified, the backup point in time since the last full backup, the backup data will become increasingly large, data recovery, simply restore the last full backup and a recent differential backup.

  • Incremental Backup: Only those files will be backed up in modified in the last full or incremental backup after more than full backup or incremental backup for the last time point in time, only the backup data changes between the , so the amount of data backup is also small, small footprint, fast backup speed, but recovery, the need to start from the last full backup of all the increment between successively an incremental backup restore damaged once the intermediate data will result in loss of data.

Third, the common backup methods

MySQL database backup may take a variety of ways, such as direct package database file (physical cold backup), dedicated backup tool (the mysqldump), binary log incremental backup, third-party backup tools.

1, the physical cold backup

You need to be in the closed state when the physical database cold backup, can better ensure the integrity of the database. Physical cold backup is generally used for non-core businesses, such services are generally allowed to interrupt the physical characteristics of the cold backup is fast and recovery is the most simple.

2, or dedicated backup tools mysqldump mysqlhotcopy

mysqldump and mysqlhotcopy program can do backup. mysqqldump client backup program custom logic can be performed to generate a set of object definitions, and reproduce the original database table data SQL statement. It can dump a MySQL database to multiple, back it up or transfer to a remote SQL server. mysqldump is more general because it can back up the various tables. mysqlhotcopy only available on some storage engines.

3, incremental backups by enabling the binary log

MySQL supports incremental backups, you must enable binary logging performed incremental backups. The binary log files provide users with replication, database after performing the backup point changes to the information needed for recovery. If an incremental backup (containing data modifications made since the last full or incremental backup), you need to refresh the binary log.

Fourth, the full database backup operation

1, the backup before preparation

[root@01 ~]# mysqladmin -u root password  <!--mysql数据库设置密码-->
New password:             <!--输入密码-->
Confirm new password:        <!--确认密码-->
[root@centos01 ~]# mysql -uroot -ppwd@123    <!--登录MySQL数据库-->
mysql> create database benet;        <!--创建benet数据库-->
mysql> use benet;             <!--切换到benet数据库创建表-->
mysql> create table 一班学生成绩 (姓名 char(3),班级 char(5),学号 char(8),语文 char(3),
数学char(3),英语 char(3),理综 char(3), primary key (学号));  
<!--创建表,表名字为一班学生成绩,第一列名字是姓名,第二列名字为班级,第三列名字
为学号,第四列名字为语文,第五列名字为数学,第六列名字为英语,第七列名字为理综-->
mysql> insert into 一班学生成绩 value ('张三','一班','20170822','110','105','92','235');  
                   <!--表中插入数据-->
mysql>  insert into 一班学生成绩 value ('李四','一班','20170820','95','115','110','260');  
                   <!--表中插入数据-->
mysql> insert into 一班学生成绩 value ('王五','一班','20170818','95','103','108','270');  
                   <!--表中插入数据-->
mysql> insert into 一班学生成绩 value ('赵六','一班','20170816','100','109','112','265'); 
                   <!--表中插入数据-->
mysql> select * from benet.一班学生成绩;   <!--查看一班学生成绩表中所有数据-->

2, physical cold backup and recovery

Physical cold backup is generally packaged with tar command directly to the database folder, and need to use the "systemctl stop mysqld" Before backup command to shut down mysql service.

1) Backup Database

Create a / bak directory as the backup data storage path, use the backup tar file is created. Backup of the entire database folders full backup.

[root@centos01 ~]# systemctl stop mysqld  <!--停止mysql服务-->
[root@centos01 ~]mkdir /bak/   <!--创建存储备份目录-->
[root@centos01 ~]# tar zcf /bak/mysql_all-$(date +%F).mysql.gz /usr/local/mysql/data/    
                 <!--直接tar打包数据库文件-->
[root@centos01 ~]# ls /bak/     <!--查看备份的数据-->
-rw-r--r-- 1 root root 766598 10月 31 03:57 /bak/mysql_all-2019-10-31.mysql.gz

2) to restore the database

[root@centos01 ~]mkdir test  <!--创建恢复数据目录-->
[root@centos01 ~]# tar zxvf /bak/mysql_all-2019-10-31.mysql.gz  -C ./test/   
                <!--解压缩备份数据到恢复目录-->
[root@centos01 data]# cd /usr/local/mysql/data/  <!--进入数据原始位置-->
[root@centos01 data]# rm -rf ./*  <!--删除数据-->
[root@centos01 ~]# cd ./test/usr/local/mysql/data/  <!--切换到恢复目录-->
[root@centos01 date]#mv ./* /usr/local/mysql/data/    <!--将恢复目录数据恢复到原始位置-->
[root@centos01 ~]# systemctl start mysqld  <!--启动mysql服务-->

3, mysqldump backup and recovery

You can be specified by the mysqldump command library, table or all of the library export to SQL scripts, easy to use the command on a different version of the MySQL server.

1) backup and recovery of all databases

[root@centos01 ~]# mysqldump -uroot -ppwd@123 --opt --all-databases > ./test/benet_databases.sql     <!--备份所有库,opt选项是优化执行速度-->
[root@centos01 ~]# mysql -uroot -p     <!--登录数据库-->
Enter password:          <!--数据密码-->
mysql> show databases;         <!--查看所有数据库-->
+--------------------+
| Database           |
+--------------------+
| information_schema |
| benet              |
| mysql              |
| performance_schema |
| test               |
+--------------------+
mysql> drop database benet;  <!--删除benet数据库-->
mysql> show databases;      <!--查看数据库是否删除-->
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
[root@centos01 ~]# mysql -u root -p < ./test/benet_databases.sql 
Enter password:     <!--恢复所有数据库-->
mysql> show databases;     <!--查看数据库是否恢复-->
+--------------------+
| Database           |
+--------------------+
| information_schema |
| benet              |
| mysql              |
| performance_schema |
| test               |
+--------------------+
mysql> source ./test/benet_databases.sql 
             <!--也可以通过这种方法恢复误删除的数据库-->

2) backup and recovery of database tables

[root@centos01 ~]# mysqldump -uroo t -ppwd@123 benet 一班学生成绩 > ./test/benet_一班学生成绩.sql   
                         <!--备份数据库下的表-->
[root@centos01 ~]# mysql -uroot -p       <!--登录数据库-->
Enter password:        <!--输入密码-->
mysql> use benet;      <!--切换到benet数据库-->
mysql> drop table 一班学生成绩;      <!--删除一班学生成绩表-->
mysql> show tables;        <!--查看表是否删除--> 
Empty set (0.00 sec)
[root@centos01 ~]# mysql -uroot -p benet < ./test/benet_一班学生成绩.sql  
                           <!--恢复误删除的表-->
[root@centos01 ~]# mysql -uroot -p    <!--登录数据库-->
Enter password:           <!--输入密码-->
mysql> use benet;         <!--切换到benet数据库-->
Database changed
mysql> show tables;    <!--查看误删除的表是否恢复-->
+--------------------+
| Tables_in_benet    |
+--------------------+
| 一班学生成绩       |
+--------------------+
1 row in set (0.00 sec)

Five, MySQL incremental backup and recovery

Using mysqldump full backup, the backup data in the duplicate data backup and recovery time is too long. The incremental backup is a backup file or content added or changed since the last backup after.

1, MySQL incremental backup features

With full backup, incremental backup is no duplication of data, not the amount of backup time is short; but its recovery trouble, after the last full backup requires a full backup and all incremental backups can be restored, but also for all incremental backups one by one thrust reverser recovery. The binary log can be provided by MySQL indirectly incremental backups.

2, MySQL incremental backup and recovery

Save the binary log all updated or may update the database operation. Binary log recording starts after the start the MySQL server, and reaches a large value set in the binary log file or flush logs after receiving the command to re-create a new log file, binary file generated sequence, and in a timely manner to save these logs to safety storage location, to complete a period of the incremental backup.
To implement the method of MySQL incremental backup, you must first turn on binary logging, open the MySQL binary log function is as follows:

[root@centos01 ~]# vim /etc/my.cnf       <!--进入MySQL配置文件-->
.......    <!--此处省略部分内容-->
log-bin=mysql-bin      <!--开启二进制日志功能-->
[root@centos01 ~]# systemctl restart mysqld   <!--重启MySQL服务-->
[root@centos01 ~]# ls -l /usr/local/mysql/data/
......             <!--此处省略部分内容-->
-rw-rw---- 1 mysql mysql    27299 10月 31 00:00 mysql-bin.000001
-rw-rw---- 1 mysql mysql  1031892 10月 31 00:00 mysql-bin.000002
-rw-rw---- 1 mysql mysql     1574 10月 31 14:13 mysql-bin.000003
-rw-rw---- 1 mysql mysql   507535 11月  1 09:37 mysql-bin.000004
-rw-rw---- 1 mysql mysql   507229 11月  1 09:40 mysql-bin.000005
-rw-rw---- 1 mysql mysql       95 11月  1 09:37 mysql-bin.index
drwx------ 2 mysql mysql     4096 10月 31 00:00 performance_schema
drwxr-xr-x 2 mysql mysql       20 10月 30 23:56 test

1) incremental backup

[root@centos01 ~]# mysqladmin -uroot -ppwd@123 flush-logs  <!--刷新二进制日志-->
[root@centos01 ~]# ls -l /usr/local/mysql/data/     <!--查看二进制日志文件-->
......   <!--此处省略部分内容-->
-rw-rw---- 1 mysql mysql    27299 10月 31 00:00 mysql-bin.000001
-rw-rw---- 1 mysql mysql  1031892 10月 31 00:00 mysql-bin.000002
-rw-rw---- 1 mysql mysql     1574 10月 31 14:13 mysql-bin.000003
-rw-rw---- 1 mysql mysql   507535 11月  1 09:37 mysql-bin.000004
-rw-rw---- 1 mysql mysql   507272 11月  1 09:49 mysql-bin.000005
-rw-rw---- 1 mysql mysql      107 11月  1 09:49 mysql-bin.000006
-rw-rw---- 1 mysql mysql      114 11月  1 09:49 mysql-bin.index
drwx------ 2 mysql mysql     4096 10月 31 00:00 performance_schema
drwxr-xr-x 2 mysql mysql       20 10月 30 23:56 test
[root@centos01 ~]# mysql -uroot -ppwd@123  <!--登录mysql数据库-->
mysql> use benet;           <!--切换到benet数据库-->
mysql> insert into 一班学生成绩 value ('李宁','二班','20170824','92','98','105','235');            
                    <!--录入新的数据-->
Query OK, 1 row affected (0.01 sec)
mysql> insert into 一班学生成绩 value ('陈铭','二班','20170826','111','107','96','204');           
                    <!--录入新的数据-->
Query OK, 1 row affected (0.00 sec)
mysql> select *from 一班学生成绩;    <!--查看新数据是否录入-->
+--------+--------+----------+--------+--------+--------+--------+
| 姓名   | 班级   | 学号     | 语文   | 数学   | 英语   | 理综   |
+--------+--------+----------+--------+--------+--------+--------+
| 赵六   | 一班   | 20170816 | 100    | 109    | 112    | 265    |
| 王五   | 一班   | 20170818 | 95     | 103    | 108    | 270    |
| 李四   | 一班   | 20170820 | 95     | 115    | 110    | 260    |
| 张三   | 一班   | 20170822 | 110    | 105    | 92     | 235    |
| 李宁   | 二班   | 20170824 | 92     | 98     | 105    | 235    |
| 陈铭   | 二班   | 20170826 | 111    | 107    | 96     | 204    |
+--------+--------+----------+--------+--------+--------+--------+
6 rows in set (0.00 sec)
[root@centos01 ~]# mysqladmin -uroot -ppwd@123 flush-logs  
                          <!--刷新二进制日志-->
[root@centos01 ~]# ls -l /usr/local/mysql/data/    
                               <!--查看二进制日志文件-->
......          <!--此处省略部分内容-->
-rw-rw---- 1 mysql mysql    27299 10月 31 00:00 mysql-bin.000001
-rw-rw---- 1 mysql mysql  1031892 10月 31 00:00 mysql-bin.000002
-rw-rw---- 1 mysql mysql     1574 10月 31 14:13 mysql-bin.000003
-rw-rw---- 1 mysql mysql   507535 11月  1 09:37 mysql-bin.000004
-rw-rw---- 1 mysql mysql   507272 11月  1 09:49 mysql-bin.000005
-rw-rw---- 1 mysql mysql      649 11月  1 09:58 mysql-bin.000006
-rw-rw---- 1 mysql mysql      107 11月  1 09:58 mysql-bin.000007
-rw-rw---- 1 mysql mysql      133 11月  1 09:58 mysql-bin.index
drwx------ 2 mysql mysql     4096 10月 31 00:00 performance_schema
drwxr-xr-x 2 mysql mysql       20 10月 30 23:56 test
[root@centos01 ~]# cp /usr/local/mysql/data/mysql-bin.000006 /root/test/   
                            <!--复制二进制日志-->

2) Analog misuse delete a group of student achievement table

[root@centos01 ~]# mysql -uroot -ppwd@123 -e 'drop table benet.一班学生成绩;'       
                    <!--删除一班学生成绩表-->
[root@centos01 ~]# mysql -uroot -ppwd@123 -e 'select * from benet.一班学生成绩;'   
                      <!--查看表是否删除-->
ERROR 1146 (42S02) at line 1: Table 'benet.一班学生成绩' doesn't exist

3) to recover accidentally deleted table

[root@centos01 ~]# mysql -uroot -ppwd@123 < ./test/benet_databases.sql   
                     <!--恢复完全备份-->
[root@centos01 ~]# mysql -uroot -ppwd@123 -e 'select * from benet.一班学生成绩;'        
                        <!--查看完全备份数据是否恢复-->
+--------+--------+----------+--------+--------+--------+--------+
| 姓名   | 班级   | 学号     | 语文   | 数学   | 英语   | 理综   |
+--------+--------+----------+--------+--------+--------+--------+
| 赵六   | 一班   | 20170816 | 100    | 109    | 112    | 265    |
| 王五   | 一班   | 20170818 | 95     | 103    | 108    | 270    |
| 李四   | 一班   | 20170820 | 95     | 115    | 110    | 260    |
| 张三   | 一班   | 20170822 | 110    | 105    | 92     | 235    |
+--------+--------+----------+--------+--------+--------+--------+
[root@centos01 ~]# mysqlbinlog --no-defaults /root/test/mysql-bin.000006 |mysql -u root -p 
                   <!--恢复增量备份-->
Enter password:       <!--输入密码-->
[root@centos01 ~]# mysql -uroot -ppwd@123 -e 'select * from benet.一班学生成绩;'      
                     <!--查看增量恢复数据是否恢复-->
+--------+--------+----------+--------+--------+--------+--------+
| 姓名   | 班级   | 学号     | 语文   | 数学   | 英语   | 理综   |
+--------+--------+----------+--------+--------+--------+--------+
| 赵六   | 一班   | 20170816 | 100    | 109    | 112    | 265    |
| 王五   | 一班   | 20170818 | 95     | 103    | 108    | 270    |
| 李四   | 一班   | 20170820 | 95     | 115    | 110    | 260    |
| 张三   | 一班   | 20170822 | 110    | 105    | 92     | 235    |
| 李宁   | 二班   | 20170824 | 92     | 98     | 105    | 235    |
| 陈铭   | 二班   | 20170826 | 111    | 107    | 96     | 204    |
+--------+--------+----------+--------+--------+--------+--------+

3, location-based recovery

[root@centos01 ~]# mysql -uroot -ppwd@123 -e 'drop table benet.一班学生成绩;'   
                <!--删除一班学生成绩表-->
[root@centos01 ~]# mysql -uroot -ppwd@123 -e 'select * from benet.一班学生成绩;'  
                 <!--查看表是否删除-->
ERROR 1146 (42S02) at line 1: Table 'benet.一班学生成绩' doesn't exist
[root@centos01 ~]# mysql -uroot -ppwd@123 < ./test/benet_databases.sql     
               <!--恢复完全备份-->
[root@centos01 ~]# mysql -uroot -ppwd@123 -e 'select * from benet.一班学生成绩;'     
               <!--查看完全备份是否恢复-->
+--------+--------+----------+--------+--------+--------+--------+
| 姓名   | 班级   | 学号     | 语文   | 数学   | 英语   | 理综   |
+--------+--------+----------+--------+--------+--------+--------+
| 赵六   | 一班   | 20170816 | 100    | 109    | 112    | 265    |
| 王五   | 一班   | 20170818 | 95     | 103    | 108    | 270    |
| 李四   | 一班   | 20170820 | 95     | 115    | 110    | 260    |
| 张三   | 一班   | 20170822 | 110    | 105    | 92     | 235    |
+--------+--------+----------+--------+--------+--------+--------+
[root@centos01 ~]# mysqlbinlog --no-defaults /root/test/mysql-bin.000006       
                <!--查看二进制日志文件确认恢复的位置或时间点-->
......         <!--此处省略部分内容-->
# at 176                  <!--at就是我们称之为操作ID,下面紧跟的是时间标记-->
#191101  9:55:33 server id 1  end_log_pos 329   Query   thread_id=9 exec_time=0 error_code=0
use benet/*!*/;
SET TIMESTAMP=1572573333/*!*/;
insert into 一班学生成绩 value ('李宁','二班','20170824','92','98','105','235')
/*!*/;
# at 329
#191101  9:55:33 server id 1  end_log_pos 356   Xid = 278
COMMIT/*!*/;
# at 356
#191101  9:55:43 server id 1  end_log_pos 425   Query   thread_id=9 exec_time=0 error_code=0
SET TIMESTAMP=1572573343/*!*/;
BEGIN
/*!*/;
# at 425       <!--at就是我们称之为操作ID,下面紧跟的是时间标记-->
#191101  9:55:43 server id 1  end_log_pos 579   Query   thread_id=9 exec_time=0 error_code=0
SET TIMESTAMP=1572573343/*!*/;
insert into 一班学生成绩 value ('陈铭','二班','20170826','111','107','96','204')
/*!*/;
[root@centos01 ~]# mysqlbinlog --no-defaults --stop-position='425' /root/test/mysql-bin.000006 |mysql -uroot -p       <!--基于ID恢复增量备份-->
Enter password:       <!--输入密码-->
[root@centos01 ~]# mysql -uroot -ppwd@123 -e 'select * from benet.一班学生成绩;'    
               <!--查看数据是否恢复-->
+--------+--------+----------+--------+--------+--------+--------+
| 姓名   | 班级   | 学号     | 语文   | 数学   | 英语   | 理综   |
+--------+--------+----------+--------+--------+--------+--------+
| 赵六   | 一班   | 20170816 | 100    | 109    | 112    | 265    |
| 王五   | 一班   | 20170818 | 95     | 103    | 108    | 270    |
| 李四   | 一班   | 20170820 | 95     | 115    | 110    | 260    |
| 张三   | 一班   | 20170822 | 110    | 105    | 92     | 235    |
| 李宁   | 二班   | 20170824 | 92     | 98     | 105    | 235    |
+--------+--------+----------+--------+--------+--------+--------+

The above command "--stop-position" is specified stop position, if only to restore information "Ming", the skip information "Li Ning" recovery, you can use the "--start-position" option specifies began to recover data s position. Then the recovered data is the start until the last binary log file from the specified location.

[root@centos01 ~]# mysql -uroot -ppwd@123 -e 'drop table benet.一班学生成绩;'    
                   <!--删除一班学生成绩表-->
[root@centos01 ~]# mysql -uroot -ppwd@123 -e 'select * from benet.一班学生成绩;'  
                  <!--查看表是否删除-->
ERROR 1146 (42S02) at line 1: Table 'benet.一班学生成绩' doesn't exist
[root@centos01 ~]# mysql -uroot -ppwd@123 < ./test/benet_databases.sql      
                          <!--恢复完全备份-->
[root@centos01 ~]# mysqlbinlog --no-defaults --start-position='425' /root/test/mysql-bin.000006 |mysql -uroot -p       <!--基于ID恢复增量备份-->
Enter password:        <!--输入密码-->
[root@centos01 ~]# mysql -uroot -ppwd@123 -e 'select * from benet.一班学生成绩;'    
                 <!--查看数据是否恢复-->
+--------+--------+----------+--------+--------+--------+--------+
| 姓名   | 班级   | 学号     | 语文   | 数学   | 英语   | 理综   |
+--------+--------+----------+--------+--------+--------+--------+
| 赵六   | 一班   | 20170816 | 100    | 109    | 112    | 265    |
| 王五   | 一班   | 20170818 | 95     | 103    | 108    | 270    |
| 李四   | 一班   | 20170820 | 95     | 115    | 110    | 260    |
| 张三   | 一班   | 20170822 | 110    | 105    | 92     | 235    |
| 陈铭   | 二班   | 20170826 | 111    | 107    | 96     | 204    |
+--------+--------+----------+--------+--------+--------+--------+

4, based on the point in time recovery

Options used data recovery time is based on the point "--stop-datetime", is also the time specified binary log resulting query. About the implementation of the operation can be achieved only to recover data before 9:55:43, that is not recovery information "Ming" is.

[root@centos01 ~]# mysql -uroot -ppwd@123 -e 'drop table benet.一班学生成绩;' 
                      <!--删除一班学生成绩表-->
[root@centos01 ~]# mysql -uroot -ppwd@123 -e 'select * from benet.一班学生成绩;'  
                 <!--查看表是否删除-->
ERROR 1146 (42S02) at line 1: Table 'benet.一班学生成绩' doesn't exist
[root@centos01 ~]# mysql -uroot -ppwd@123 < ./test/benet_databases.sql    
                   <!--恢复完全备份-->
[root@centos01 ~]# mysqlbinlog --no-defaults --stop-datetime='2019-11-01  9:55:43' /root/test/mysql-bin.000006 |mysql -uroot -p     
                         <!--基于时间点恢复增量备份-->
Enter password:       <!--输入密码-->
[root@centos01 ~]# mysql -uroot -ppwd@123 -e 'select * from benet.一班学生成绩;'    
                           <!--查看数据是否恢复-->
+--------+--------+----------+--------+--------+--------+--------+
| 姓名   | 班级   | 学号     | 语文   | 数学   | 英语   | 理综   |
+--------+--------+----------+--------+--------+--------+--------+
| 赵六   | 一班   | 20170816 | 100    | 109    | 112    | 265    |
| 王五   | 一班   | 20170818 | 95     | 103    | 108    | 270    |
| 李四   | 一班   | 20170820 | 95     | 115    | 110    | 260    |
| 张三   | 一班   | 20170822 | 110    | 105    | 92     | 235    |
| 李宁   | 二班   | 20170824 | 92     | 98     | 105    | 235    |
+--------+--------+----------+--------+--------+--------+--------+

Do the following information can be achieved only recover information "Ming" skipped "Li Ning" recovery

[root@centos01 ~]# mysql -uroot -ppwd@123 -e 'drop table benet.一班学生成绩;'   
                      <!--删除一班学生成绩表-->
[root@centos01 ~]# mysql -uroot -ppwd@123 -e 'select * from benet.一班学生成绩;'    
                 <!--查看表是否删除-->
ERROR 1146 (42S02) at line 1: Table 'benet.一班学生成绩' doesn't exist
[root@centos01 ~]# mysql -uroot -ppwd@123 < ./test/benet_databases.sql     
                         <!--恢复完全备份-->
[root@centos01 ~]# mysqlbinlog --no-defaults --start-datetime='2019-11-01 9:55:43'
/root/test/mysql-bin.000006 |mysql -uroot -p      
                      <!--基于时间恢复增量备份-->
Enter password:        <!--输入密码-->
[root@centos01 ~]# mysql -uroot -ppwd@123 -e 'select * from benet.一班学生成绩;'    
                       <!--查看数据是否恢复-->
+--------+--------+----------+--------+--------+--------+--------+
| 姓名   | 班级   | 学号     | 语文   | 数学   | 英语   | 理综   |
+--------+--------+----------+--------+--------+--------+--------+
| 赵六   | 一班   | 20170816 | 100    | 109    | 112    | 265    |
| 王五   | 一班   | 20170818 | 95     | 103    | 108    | 270    |
| 李四   | 一班   | 20170820 | 95     | 115    | 110    | 260    |
| 张三   | 一班   | 20170822 | 110    | 105    | 92     | 235    |
| 陈铭   | 二班   | 20170826 | 111    | 107    | 96     | 204    |
+--------+--------+----------+--------+--------+--------+--------+

Guess you like

Origin www.linuxidc.com/Linux/2019-11/161427.htm