IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 大数据 -> mysql数据库备份与恢复 -> 正文阅读

[大数据]mysql数据库备份与恢复

1 数据库常用备份方案

数据库备份方案:

  • 全量备份
  • 增量备份
  • 差异备份
备份方案特点
全量备份全量备份就是指对某一个时间点上的所有数据或应用进行的一个完全拷贝。 数据恢复快。 备份时间长
增量备份增量备份是指在一次全备份或上一次增量备份后,以后每次的备份只需备份 与前一次相比增加和者被修改的文件。这就意味着,第一次增量备份的对象 是进行全备后所产生的增加和修改的文件;第二次增量备份的对象是进行第一次增量 备份后所产生的增加和修改的文件,如此类推。 没有重复的备份数据 备份时间短 恢复数据时必须按一定的顺序进行
差异备份备份上一次的完全备份后发生变化的所有文件。 差异备份是指在一次全备份后到进行差异备份的这段时间内 对那些增加或者修改文件的备份。在进行恢复时,我们只需对第一次全量备份和最后一次差异备份进行恢复。

2 mysql备份工具mysqldump

//语法:
    mysqldump [OPTIONS] database [tables ...]
    mysqldump [OPTIONS] --all-databases [OPTIONS]
    mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]
    
//常用的OPTIONS:
    -uUSERNAME      //指定数据库用户名
    -hHOST          //指定服务器主机,请使用ip地址
    -pPASSWORD      //指定数据库用户的密码
    -P#             //指定数据库监听的端口,这里的#需用实际的端口号代替,如-P3307
 
// 备份整个数据库
[root@192 ~]# mysqldump -uroot -p123 --all-databases > all-$(date '+%Y%m%f%H%M%S').sql
mysqldump: [Warning] Using a password on the command line interface can be insecure.
[root@192 ~]# ls
all-202206%f183142.sql  anaconda-ks.cfg
// 备份school库的tb_course
[root@192 ~]# mysqldump -uroot -p123 school tb_course > tb_course.sql
mysqldump: [Warning] Using a password on the command line interface can be insecure.
[root@192 ~]# ls
all-202206%f183142.sql  anaconda-ks.cfg  tb_course.sql


// 备份school库
[root@192 ~]# mysqldump -uroot -p123 school > school.sql
mysqldump: [Warning] Using a password on the command line interface can be insecure.
[root@192 ~]# ls
all-202206%f183142.sql  anaconda-ks.cfg  school.sql  tb_course.sql


3 mysql数据恢复

mysql> drop database school;   // 删除数据库
Query OK, 2 rows affected (0.02 sec)

mysql> show databases;  // 查看删除
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)

[root@192 ~]# mysql -uroot -p123 < all-202206%f183142.sql  // 数据恢复
mysql: [Warning] Using a password on the command line interface can be insecure.


mysql> show databases;  // 查看恢复
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| school             |
+--------------------+
4 rows in set (0.00 sec)

mysql> 
// 恢复school库中tb_course表
mysql> drop table tb_course;  //删除tb_course表
Query OK, 0 rows affected (0.00 sec)

mysql> show tables; // 查看
+------------------+
| Tables_in_school |
+------------------+
| tb_students_info |
+------------------+
1 row in set (0.00 sec)


4 差异备份与恢复

4.1 mysql差异备份

开启MySQL服务器的二进制日志功能

[root@192 ~]# vim /etc/my.cnf 

[root@192 ~]# cd /opt/data
[root@192 data]# ll
总用量 123004
-rw-r-----. 1 mysql mysql    38035 630 18:18 192.168.183.139.err
-rw-r-----. 1 mysql mysql       56 628 20:32 auto.cnf
-rw-------. 1 mysql mysql     1680 628 20:32 ca-key.pem
-rw-r--r--. 1 mysql mysql     1112 628 20:32 ca.pem
-rw-r--r--. 1 mysql mysql     1112 628 20:32 client-cert.pem
-rw-------. 1 mysql mysql     1680 628 20:32 client-key.pem
-rw-r-----. 1 mysql mysql      328 628 22:34 ib_buffer_pool
-rw-r-----. 1 mysql mysql 12582912 630 19:29 ibdata1
-rw-r-----. 1 mysql mysql 50331648 630 19:29 ib_logfile0
-rw-r-----. 1 mysql mysql 50331648 628 20:32 ib_logfile1
-rw-r-----. 1 mysql mysql 12582912 630 18:54 ibtmp1
-rw-r-----. 1 mysql mysql     4224 630 08:39 localhost.err
-rw-r-----. 1 mysql mysql    15963 628 21:50 localhost.localdomain.err
drwxr-x---. 2 mysql mysql     4096 630 19:14 mysql
-rw-r-----. 1 mysql mysql        5 630 18:18 mysql.pid
drwxr-x---. 2 mysql mysql     8192 628 20:32 performance_schema
-rw-------. 1 mysql mysql     1680 628 20:32 private_key.pem
-rw-r--r--. 1 mysql mysql      452 628 20:32 public_key.pem
drwxr-x---. 2 mysql mysql      118 630 19:27 school
-rw-r--r--. 1 mysql mysql     1112 628 20:32 server-cert.pem
-rw-------. 1 mysql mysql     1676 628 20:32 server-key.pem
[root@192 data]# systemctl restart mariadb
Failed to restart mariadb.service: Unit mariadb.service not found.
[root@192 data]# systemctl restart mysqld.service 
[root@192 data]# ll
总用量 123020
-rw-r-----. 1 mysql mysql    46186 630 19:46 192.168.183.139.err
-rw-r-----. 1 mysql mysql       56 628 20:32 auto.cnf
-rw-------. 1 mysql mysql     1680 628 20:32 ca-key.pem
-rw-r--r--. 1 mysql mysql     1112 628 20:32 ca.pem
-rw-r--r--. 1 mysql mysql     1112 628 20:32 client-cert.pem
-rw-------. 1 mysql mysql     1680 628 20:32 client-key.pem
-rw-r-----. 1 mysql mysql     1084 630 19:46 ib_buffer_pool
-rw-r-----. 1 mysql mysql 12582912 630 19:46 ibdata1
-rw-r-----. 1 mysql mysql 50331648 630 19:46 ib_logfile0
-rw-r-----. 1 mysql mysql 50331648 628 20:32 ib_logfile1
-rw-r-----. 1 mysql mysql 12582912 630 19:46 ibtmp1
-rw-r-----. 1 mysql mysql     4224 630 08:39 localhost.err
-rw-r-----. 1 mysql mysql    15963 628 21:50 localhost.localdomain.err
drwxr-x---. 2 mysql mysql     4096 630 19:14 mysql
-rw-r-----. 1 mysql mysql      154 630 19:46 mysql_bin.000001
-rw-r-----. 1 mysql mysql       19 630 19:46 mysql_bin.index
-rw-r-----. 1 mysql mysql        7 630 19:46 mysql.pid
drwxr-x---. 2 mysql mysql     8192 628 20:32 performance_schema
-rw-------. 1 mysql mysql     1680 628 20:32 private_key.pem
-rw-r--r--. 1 mysql mysql      452 628 20:32 public_key.pem
drwxr-x---. 2 mysql mysql      118 630 19:27 school
-rw-r--r--. 1 mysql mysql     1112 628 20:32 server-cert.pem
-rw-------. 1 mysql mysql     1676 628 20:32 server-key.pem
//完全备份
[root@192 ~]# mysqldump -uroot -p123 --single-transaction --flush-logs --master-data=2 --all-databases --delete-master-logs > all-$(date '+%Y%m%f%H%M%S').sql
mysqldump: [Warning] Using a password on the command line interface can be insecure.
[root@192 ~]# ls
all-202206%f183142.sql  anaconda-ks.cfg  tb_course.sql
all-202206%f202155.sql  school.sql
// 添加新的表
mysql> create table info(id int not null primary key auto_increment,name
varchar(10));
Query OK, 0 rows affected (0.00 sec)

mysql> insert info(name) values('tom'),('jerry'),('zhangsan');
Query OK, 3 rows affected (0.00 sec)
Records: 3  Duplicates: 0  Warnings: 0
mysql> select * from info;
+----+----------+
| id | name     |
+----+----------+
|  1 | tom      |
|  2 | jerry    |
|  3 | zhangsan |
+----+----------+
3 rows in set (0.00 sec)
在school库中添加一列Linux
mysql> select * from tb_course;
+----+-------------+
| id | course_name |
+----+-------------+
|  1 | Java        |
|  2 | MySQL       |
|  3 | Python      |
|  4 | Go          |
|  5 | C++         |
|  6 | Html        |
+----+-------------+
6 rows in set (0.00 sec)

mysql> insert tb_course(course_name) value('Linux');
Query OK, 1 row affected (0.00 sec)

mysql> select * from tb_course;
+----+-------------+
| id | course_name |
+----+-------------+
|  1 | Java        |
|  2 | MySQL       |
|  3 | Python      |
|  4 | Go          |
|  5 | C++         |
|  6 | Html        |
|  7 | Linux       |
+----+-------------+
7 rows in set (0.00 sec)
// 修改school库中tb_students_info表中的id为10的height为190
mysql> select * from tb_students_info;
+----+--------+------+------+--------+-----------+
| id | name   | age  | sex  | height | course_id |
+----+--------+------+------+--------+-----------+
|  1 | Dany   |   25 | M    |    160 |         1 |
|  2 | Green  |   23 | M    |    158 |         2 |
|  3 | Henry  |   23 | F    |    185 |         1 |
|  4 | Jane   |   22 | M    |    162 |         3 |
|  5 | Jim    |   24 | F    |    175 |         2 |
|  6 | John   |   21 | F    |    172 |         4 |
|  7 | Lily   |   22 | M    |    165 |         4 |
|  8 | Susan  |   23 | M    |    170 |         5 |
|  9 | Thomas |   22 | F    |    178 |         5 |
| 10 | Tom    |   23 | F    |    165 |         5 |
| 11 | Liming |   22 | M    |    180 |         7 |
+----+--------+------+------+--------+-----------+
11 rows in set (0.00 sec)

mysql> update tb_students_info set height = 190 where id = 10;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> select * from tb_students_info;
+----+--------+------+------+--------+-----------+
| id | name   | age  | sex  | height | course_id |
+----+--------+------+------+--------+-----------+
|  1 | Dany   |   25 | M    |    160 |         1 |
|  2 | Green  |   23 | M    |    158 |         2 |
|  3 | Henry  |   23 | F    |    185 |         1 |
|  4 | Jane   |   22 | M    |    162 |         3 |
|  5 | Jim    |   24 | F    |    175 |         2 |
|  6 | John   |   21 | F    |    172 |         4 |
|  7 | Lily   |   22 | M    |    165 |         4 |
|  8 | Susan  |   23 | M    |    170 |         5 |
|  9 | Thomas |   22 | F    |    178 |         5 |
| 10 | Tom    |   23 | F    |    190 |         5 |
| 11 | Liming |   22 | M    |    180 |         7 |
+----+--------+------+------+--------+-----------+
11 rows in set (0.00 sec)
// 删除school库中tb_students_info表中的id为2信息
mysql> delete from tb_students_info where id = 2;
Query OK, 1 row affected (0.00 sec)

mysql> select * from tb_students_info;
+----+--------+------+------+--------+-----------+
| id | name   | age  | sex  | height | course_id |
+----+--------+------+------+--------+-----------+
|  1 | Dany   |   25 | M    |    160 |         1 |
|  3 | Henry  |   23 | F    |    185 |         1 |
|  4 | Jane   |   22 | M    |    162 |         3 |
|  5 | Jim    |   24 | F    |    175 |         2 |
|  6 | John   |   21 | F    |    172 |         4 |
|  7 | Lily   |   22 | M    |    165 |         4 |
|  8 | Susan  |   23 | M    |    170 |         5 |
|  9 | Thomas |   22 | F    |    178 |         5 |
| 10 | Tom    |   23 | F    |    190 |         5 |
| 11 | Liming |   22 | M    |    180 |         7 |
+----+--------+------+------+--------+-----------+
10 rows in set (0.00 sec)

mysql> 

// 删除school库

mysql> drop database school;
Query OK, 3 rows affected (0.02 sec)
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)
//  刷新创建新的二进制日志
[root@192 ~]# mysqladmin -uroot -p123 flush-logs
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
[root@192 data]# ll
总用量 123020
-rw-r-----. 1 mysql mysql    46186 630 19:46 192.168.183.139.err
-rw-r-----. 1 mysql mysql       56 628 20:32 auto.cnf
-rw-------. 1 mysql mysql     1680 628 20:32 ca-key.pem
-rw-r--r--. 1 mysql mysql     1112 628 20:32 ca.pem
-rw-r--r--. 1 mysql mysql     1112 628 20:32 client-cert.pem
-rw-------. 1 mysql mysql     1680 628 20:32 client-key.pem
-rw-r-----. 1 mysql mysql     1084 630 19:46 ib_buffer_pool
-rw-r-----. 1 mysql mysql 12582912 630 19:46 ibdata1
-rw-r-----. 1 mysql mysql 50331648 630 19:46 ib_logfile0
-rw-r-----. 1 mysql mysql 50331648 628 20:32 ib_logfile1
-rw-r-----. 1 mysql mysql 12582912 630 20:21 ibtmp1
-rw-r-----. 1 mysql mysql     4224 630 08:39 localhost.err
-rw-r-----. 1 mysql mysql    15963 628 21:50 localhost.localdomain.err
drwxr-x---. 2 mysql mysql     4096 630 19:14 mysql
-rw-r-----. 1 mysql mysql      154 630 20:21 mysql_bin.000003
-rw-r-----. 1 mysql mysql       19 630 20:21 mysql_bin.index
-rw-r-----. 1 mysql mysql        7 630 19:46 mysql.pid
drwxr-x---. 2 mysql mysql     8192 628 20:32 performance_schema
-rw-------. 1 mysql mysql     1680 628 20:32 private_key.pem
-rw-r--r--. 1 mysql mysql      452 628 20:32 public_key.pem
drwxr-x---. 2 mysql mysql      118 630 19:27 school
-rw-r--r--. 1 mysql mysql     1112 628 20:32 server-cert.pem
-rw-------. 1 mysql mysql     1676 628 20:32 server-key.pem
[root@192 data]# ll
总用量 123024
-rw-r-----. 1 mysql mysql    46186 630 19:46 192.168.183.139.err
-rw-r-----. 1 mysql mysql       56 628 20:32 auto.cnf
-rw-------. 1 mysql mysql     1680 628 20:32 ca-key.pem
-rw-r--r--. 1 mysql mysql     1112 628 20:32 ca.pem
-rw-r--r--. 1 mysql mysql     1112 628 20:32 client-cert.pem
-rw-------. 1 mysql mysql     1680 628 20:32 client-key.pem
-rw-r-----. 1 mysql mysql     1084 630 19:46 ib_buffer_pool
-rw-r-----. 1 mysql mysql 12582912 630 21:16 ibdata1
-rw-r-----. 1 mysql mysql 50331648 630 21:16 ib_logfile0
-rw-r-----. 1 mysql mysql 50331648 628 20:32 ib_logfile1
-rw-r-----. 1 mysql mysql 12582912 630 20:21 ibtmp1
-rw-r-----. 1 mysql mysql     4224 630 08:39 localhost.err
-rw-r-----. 1 mysql mysql    15963 628 21:50 localhost.localdomain.err
drwxr-x---. 2 mysql mysql     4096 630 19:14 mysql
-rw-r-----. 1 mysql mysql     1762 630 21:20 mysql_bin.000003
-rw-r-----. 1 mysql mysql      154 630 21:20 mysql_bin.000004
-rw-r-----. 1 mysql mysql       38 630 21:20 mysql_bin.index
-rw-r-----. 1 mysql mysql        7 630 19:46 mysql.pid
drwxr-x---. 2 mysql mysql     8192 628 20:32 performance_schema
-rw-------. 1 mysql mysql     1680 628 20:32 private_key.pem
-rw-r--r--. 1 mysql mysql      452 628 20:32 public_key.pem
-rw-r--r--. 1 mysql mysql     1112 628 20:32 server-cert.pem
-rw-------. 1 mysql mysql     1676 628 20:32 server-key.pem
// 恢复完全备份
[root@192 ~]# mysql -uroot -p123 < all-202206%f202155.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
//检查误删数据库的位置在什么地方
mysql> show binlog events in 'mysql_bin.000003';
+------------------+------+----------------+-----------+-------------+----------------------------------------------------------------------------------------------+
| Log_name         | Pos  | Event_type     | Server_id | End_log_pos | Info                                                                                         |
+------------------+------+----------------+-----------+-------------+----------------------------------------------------------------------------------------------+
| mysql_bin.000003 |    4 | Format_desc    |        10 |         123 | Server ver: 5.7.37-log, Binlog ver: 4                                                        |
| mysql_bin.000003 |  123 | Previous_gtids |        10 |         154 |                                                                                              |
| mysql_bin.000003 |  154 | Anonymous_Gtid |        10 |         219 | SET @@SESSION.GTID_NEXT= 'ANONYMOUS'                                                         |
| mysql_bin.000003 |  219 | Query          |        10 |         375 | use `school`; create table info(id int not null primary key auto_increment,name varchar(10)) |
| mysql_bin.000003 |  375 | Anonymous_Gtid |        10 |         440 | SET @@SESSION.GTID_NEXT= 'ANONYMOUS'                                                         |
| mysql_bin.000003 |  440 | Query          |        10 |         514 | BEGIN                                                                                        |
| mysql_bin.000003 |  514 | Table_map      |        10 |         566 | table_id: 176 (school.info)                                                                  |
| mysql_bin.000003 |  566 | Write_rows     |        10 |         635 | table_id: 176 flags: STMT_END_F                                                              |
| mysql_bin.000003 |  635 | Xid            |        10 |         666 | COMMIT /* xid=955 */                                                                         |
| mysql_bin.000003 |  666 | Anonymous_Gtid |        10 |         731 | SET @@SESSION.GTID_NEXT= 'ANONYMOUS'                                                         |
| mysql_bin.000003 |  731 | Query          |        10 |         805 | BEGIN                                                                                        |
| mysql_bin.000003 |  805 | Table_map      |        10 |         862 | table_id: 174 (school.tb_course)                                                             |
| mysql_bin.000003 |  862 | Write_rows     |        10 |         908 | table_id: 174 flags: STMT_END_F                                                              |
| mysql_bin.000003 |  908 | Xid            |        10 |         939 | COMMIT /* xid=958 */                                                                         |
| mysql_bin.000003 |  939 | Anonymous_Gtid |        10 |        1004 | SET @@SESSION.GTID_NEXT= 'ANONYMOUS'                                                         |
| mysql_bin.000003 | 1004 | Query          |        10 |        1078 | BEGIN                                                                                        |
| mysql_bin.000003 | 1078 | Table_map      |        10 |        1148 | table_id: 175 (school.tb_students_info)                                                      |
| mysql_bin.000003 | 1148 | Update_rows    |        10 |        1224 | table_id: 175 flags: STMT_END_F                                                              |
| mysql_bin.000003 | 1224 | Xid            |        10 |        1255 | COMMIT /* xid=961 */                                                                         |
| mysql_bin.000003 | 1255 | Anonymous_Gtid |        10 |        1320 | SET @@SESSION.GTID_NEXT= 'ANONYMOUS'                                                         |
| mysql_bin.000003 | 1320 | Query          |        10 |        1394 | BEGIN                                                                                        |
| mysql_bin.000003 | 1394 | Table_map      |        10 |        1464 | table_id: 175 (school.tb_students_info)                                                      |
| mysql_bin.000003 | 1464 | Delete_rows    |        10 |        1521 | table_id: 175 flags: STMT_END_F                                                              |
| mysql_bin.000003 | 1521 | Xid            |        10 |        1552 | COMMIT /* xid=963 */                                                                         |
| mysql_bin.000003 | 1552 | Anonymous_Gtid |        10 |        1617 | SET @@SESSION.GTID_NEXT= 'ANONYMOUS'                                                         |
| mysql_bin.000003 | 1617 | Query          |        10 |        1715 | drop database school                                                                         |
| mysql_bin.000003 | 1715 | Rotate         |        10 |        1762 | mysql_bin.000004;pos=4                                                                       |
+------------------+------+----------------+-----------+-------------+----------------------------------------------------------------------------------------------+
27 rows in set (0.00 sec)
//使用mysqlbinlog恢复差异备份
[root@192 ~]# mysqladmin -uroot -p123 flush-logs 
mysqladmin: [Warning] Using a password on the command line interface can 
be insecure.
[root@192 ~]# mysqlbinlog --stop-position=1617 /opt/data/mysql_bin.000003   // 查看
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at 4
#220630 20:21:55 server id 10  end_log_pos 123 CRC32 0x46f3c4b5         Start: binlog v 4, server v 5.7.37-log created 220630 20:21:55
BINLOG '
Y5W9Yg8KAAAAdwAAAHsAAAAAAAQANS43LjM3LWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAEzgNAAgAEgAEBAQEEgAAXwAEGggAAAAICAgCAAAACgoKKioAEjQA
AbXE80Y=
'/*!*/;
# at 123
#220630 20:21:55 server id 10  end_log_pos 154 CRC32 0x5e99da3b         Previous-GTIDs
# [empty]
# at 154
#220630 20:30:30 server id 10  end_log_pos 219 CRC32 0x6c644617         Anonymous_GTIDlast_committed=0        sequence_number=1       rbr_only=no
SET @@SESSION.GTID_NEXT= 'ANONYMOUS'/*!*/;
# at 219
#220630 20:30:30 server id 10  end_log_pos 375 CRC32 0x744af43a         Query   thread_id=4   exec_time=0     error_code=0
use `school`/*!*/;
SET TIMESTAMP=1656592230/*!*/;
SET @@session.pseudo_thread_id=4/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
SET @@session.sql_mode=1436549152/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C utf8 *//*!*/;
SET @@session.character_set_client=33,@@session.collation_connection=33,@@session.collation_server=8/*!*/;
SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
create table info(id int not null primary key auto_increment,name varchar(10))
/*!*/;
# at 375
#220630 20:32:08 server id 10  end_log_pos 440 CRC32 0xcbbdf130         Anonymous_GTIDlast_committed=1        sequence_number=2       rbr_only=yes
/*!50718 SET TRANSACTION ISOLATION LEVEL READ COMMITTED*//*!*/;
SET @@SESSION.GTID_NEXT= 'ANONYMOUS'/*!*/;
# at 440
#220630 20:32:08 server id 10  end_log_pos 514 CRC32 0xfcca279f         Query   thread_id=4   exec_time=0     error_code=0
SET TIMESTAMP=1656592328/*!*/;
BEGIN
/*!*/;
# at 514
#220630 20:32:08 server id 10  end_log_pos 566 CRC32 0x903d7ce2         Table_map: `school`.`info` mapped to number 176
# at 566
#220630 20:32:08 server id 10  end_log_pos 635 CRC32 0x3786e3b3         Write_rows: table id 176 flags: STMT_END_F

BINLOG '
yJe9YhMKAAAANAAAADYCAAAAALAAAAAAAAEABnNjaG9vbAAEaW5mbwACAw8CCgAC4nw9kA==
yJe9Yh4KAAAARQAAAHsCAAAAALAAAAAAAAEAAgAC//wBAAAAA3RvbfwCAAAABWplcnJ5/AMAAAAI
emhhbmdzYW6z44Y3
'/*!*/;
# at 635
#220630 20:32:08 server id 10  end_log_pos 666 CRC32 0x5145b313         Xid = 955
COMMIT/*!*/;
# at 666
#220630 21:04:04 server id 10  end_log_pos 731 CRC32 0x78c994c7         Anonymous_GTIDlast_committed=2        sequence_number=3       rbr_only=yes
/*!50718 SET TRANSACTION ISOLATION LEVEL READ COMMITTED*//*!*/;
SET @@SESSION.GTID_NEXT= 'ANONYMOUS'/*!*/;
# at 731
#220630 21:04:04 server id 10  end_log_pos 805 CRC32 0x65e4279b         Query   thread_id=4   exec_time=0     error_code=0
SET TIMESTAMP=1656594244/*!*/;
BEGIN
/*!*/;
# at 805
#220630 21:04:04 server id 10  end_log_pos 862 CRC32 0x8db9305f         Table_map: `school`.`tb_course` mapped to number 174
# at 862
#220630 21:04:04 server id 10  end_log_pos 908 CRC32 0x4658400a         Write_rows: table id 174 flags: STMT_END_F

BINLOG '
RJ+9YhMKAAAAOQAAAF4DAAAAAK4AAAAAAAEABnNjaG9vbAAJdGJfY291cnNlAAIDDwIeAAJfMLmN
RJ+9Yh4KAAAALgAAAIwDAAAAAK4AAAAAAAEAAgAC//wHAAAABUxpbnV4CkBYRg==
'/*!*/;
# at 908
#220630 21:04:04 server id 10  end_log_pos 939 CRC32 0x9a360128         Xid = 958
COMMIT/*!*/;
# at 939
#220630 21:10:31 server id 10  end_log_pos 1004 CRC32 0x696fe9c0        Anonymous_GTIDlast_committed=3        sequence_number=4       rbr_only=yes
/*!50718 SET TRANSACTION ISOLATION LEVEL READ COMMITTED*//*!*/;
SET @@SESSION.GTID_NEXT= 'ANONYMOUS'/*!*/;
# at 1004
#220630 21:10:31 server id 10  end_log_pos 1078 CRC32 0xd355745c        Query   thread_id=4   exec_time=0     error_code=0
SET TIMESTAMP=1656594631/*!*/;
BEGIN
/*!*/;
# at 1078
#220630 21:10:31 server id 10  end_log_pos 1148 CRC32 0xeac7a187        Table_map: `school`.`tb_students_info` mapped to number 175
# at 1148
#220630 21:10:31 server id 10  end_log_pos 1224 CRC32 0x7d541890        Update_rows: table id 175 flags: STMT_END_F

BINLOG '
x6C9YhMKAAAARgAAAHwEAAAAAK8AAAAAAAEABnNjaG9vbAAQdGJfc3R1ZGVudHNfaW5mbwAGAw8B
DwMDBB4ABgA+h6HH6g==
x6C9Yh8KAAAATAAAAMgEAAAAAK8AAAAAAAEAAgAG///ACgAAAANUb20XAUalAAAABQAAAMAKAAAA
A1RvbRcBRr4AAAAFAAAAkBhUfQ==
'/*!*/;
# at 1224
#220630 21:10:31 server id 10  end_log_pos 1255 CRC32 0x7cb6226b        Xid = 961
COMMIT/*!*/;
# at 1255
#220630 21:14:17 server id 10  end_log_pos 1320 CRC32 0xe21f6b13        Anonymous_GTIDlast_committed=4        sequence_number=5       rbr_only=yes
/*!50718 SET TRANSACTION ISOLATION LEVEL READ COMMITTED*//*!*/;
SET @@SESSION.GTID_NEXT= 'ANONYMOUS'/*!*/;
# at 1320
#220630 21:14:17 server id 10  end_log_pos 1394 CRC32 0x8db1f932        Query   thread_id=4   exec_time=0     error_code=0
SET TIMESTAMP=1656594857/*!*/;
BEGIN
/*!*/;
# at 1394
#220630 21:14:17 server id 10  end_log_pos 1464 CRC32 0x9d225ed1        Table_map: `school`.`tb_students_info` mapped to number 175
# at 1464
#220630 21:14:17 server id 10  end_log_pos 1521 CRC32 0xe6197a37        Delete_rows: table id 175 flags: STMT_END_F

BINLOG '
qaG9YhMKAAAARgAAALgFAAAAAK8AAAAAAAEABnNjaG9vbAAQdGJfc3R1ZGVudHNfaW5mbwAGAw8B
DwMDBB4ABgA+0V4inQ==
qaG9YiAKAAAAOQAAAPEFAAAAAK8AAAAAAAEAAgAG/8ACAAAABUdyZWVuFwFNngAAAAIAAAA3ehnm
'/*!*/;
# at 1521
#220630 21:14:17 server id 10  end_log_pos 1552 CRC32 0xd592b65f        Xid = 963
COMMIT/*!*/;
# at 1552
#220630 21:16:23 server id 10  end_log_pos 1617 CRC32 0x8a00b4dc        Anonymous_GTIDlast_committed=5        sequence_number=6       rbr_only=no
SET @@SESSION.GTID_NEXT= 'ANONYMOUS'/*!*/;
BEGIN /*added by mysqlbinlog */ /*!*/;
ROLLBACK /* added by mysqlbinlog */ /*!*/;
SET @@SESSION.GTID_NEXT= 'AUTOMATIC' /* added by mysqlbinlog */ /*!*/;
DELIMITER ;
# End of log file
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
[root@192 ~]# mysqlbinlog --stop-position=1617 /opt/data/mysql_bin.000003 | mysql -uroot -p123
mysql: [Warning] Using a password on the command line interface can be insecure.
查看库和表
mysql> use school;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+------------------+
| Tables_in_school |
+------------------+
| info             |
| tb_course        |
| tb_students_info |
+------------------+
3 rows in set (0.00 sec)
mysql> select * from info;
+----+----------+
| id | name     |
+----+----------+
|  1 | tom      |
|  2 | jerry    |
|  3 | zhangsan |
+----+----------+
3 rows in set (0.00 sec)

mysql> select * from tb_course;
+----+-------------+
| id | course_name |
+----+-------------+
|  1 | Java        |
|  2 | MySQL       |
|  3 | Python      |
|  4 | Go          |
|  5 | C++         |
|  6 | Html        |
|  7 | Linux       |
+----+-------------+
7 rows in set (0.00 sec)

mysql> select * from tb_students_info;
+----+--------+------+------+--------+-----------+
| id | name   | age  | sex  | height | course_id |
+----+--------+------+------+--------+-----------+
|  1 | Dany   |   25 | M    |    160 |         1 |
|  3 | Henry  |   23 | F    |    185 |         1 |
|  4 | Jane   |   22 | M    |    162 |         3 |
|  5 | Jim    |   24 | F    |    175 |         2 |
|  6 | John   |   21 | F    |    172 |         4 |
|  7 | Lily   |   22 | M    |    165 |         4 |
|  8 | Susan  |   23 | M    |    170 |         5 |
|  9 | Thomas |   22 | F    |    178 |         5 |
| 10 | Tom    |   23 | F    |    190 |         5 |
| 11 | Liming |   22 | M    |    180 |         7 |
+----+--------+------+------+--------+-----------+
10 rows in set (0.00 sec)

  大数据 最新文章
实现Kafka至少消费一次
亚马逊云科技:还在苦于ETL?Zero ETL的时代
初探MapReduce
【SpringBoot框架篇】32.基于注解+redis实现
Elasticsearch:如何减少 Elasticsearch 集
Go redis操作
Redis面试题
专题五 Redis高并发场景
基于GBase8s和Calcite的多数据源查询
Redis——底层数据结构原理
上一篇文章      下一篇文章      查看所有文章
加:2022-07-04 22:59:50  更:2022-07-04 23:03:21 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年5日历 -2024/5/19 23:28:31-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码