Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Detailed steps for using the mysqlbinlog_flashback tool

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

The following mainly brings you the detailed steps of using mysqlbinlog_flashback tools. I hope these contents can bring you practical use, which is also the main purpose of this article that I edit the detailed steps of using mysqlbinlog_flashback tools. All right, don't talk too much nonsense, let's just read the following.

Download and install

# wget https://github.com/58daojia-dba/mysqlbinlog_flashback/archive/master.zip

Tool-related usage parameters:

[root@ops-db-test01 mysqlbinlog_flashback-master] # python mysqlbinlog_back.py-- help===log will also write to. / / mysqlbinlog_flashback.log===Usage: python mysqlbinlog_back.py [options] sample1:python mysqlbinlog_back.py-- host= "127.0.0.1"-- username= "root"-- port=43306-- password= ""-- schema=test-- table= "test5" sample2:python mysqlbinlog_back.py-host= "127.0.0.1"-- username= "root" -port=43306-- password= ""-- schema=test-- table= "test5 Test6 "- binlog_end_time=" 2016-11-05 11:27:13 "--binlog_start_file_name=" mysql-bin.000024 "--binlog_start_file_position=4-- binlog_start_time=" 2016-11-04 11:27:13 "--skip_delete-- skip_insert-- add_schema_namesample3:python mysqlbinlog_back.py-- host=" 127.0.0.1 "--username=" root "--port=43306-- Password= "--schema=test-- table=" test5 Test6 "--binlog_start_file_name=" mysql-bin.000022 "Options:-h,-- help show this help message and exit-H HOST,-- host=HOST mandatory,mysql hostname-P PORT,-- port=PORT mysql port,default 3306-u USERNAME,-- username=USERNAME mandatory,username-p PASSWORD,-- password=PASSWORD password-s SCHEMA -schema=SCHEMA mandatory,mysql schema-t TABLES,-- tables=TABLES mandatory,mysql tables,suport multiple tables,use comma as separator-N BINLOG_END_TIME,-- binlog_end_time=BINLOG_END_TIME binlog end time,format yyyy-mm-dd hh34:mi:ss Default is current time-S BINLOG_START_FILE_NAME,-- binlog_start_file_name=BINLOG_START_FILE_NAME binlog start file name,default is current logfile of db-L BINLOG_START_FILE_POSITION,-- binlog_start_file_position=BINLOG_START_FILE_POSITION binlog start file name-E BINLOG_START_TIME -- binlog_start_time=BINLOG_START_TIME binlog start time,format yyyy-mm-dd hh34:mi:ss-l OUTPUT_FILE_PATH,-- output_file_path=OUTPUT_FILE_PATH file path that sql generated,default. / log-I,-- skip_insert skip insert (WriteRowsEvent) event-U,-- skip_update skip update (UpdateRowsEvent) event-D -skip_delete skip delete (DeleteRowsEvent) event-a,-- add_schema_name add schema name for flashback sql-v,-- version version info

Second, simulate misoperation

1. Batch delete operation

Delete does not add a where condition, and the whole table is deleted. At this time, the table still has write operations.

# python mysqlbinlog_back.py-- host= "localhost"-- username= "--port=3306-- password="-- schema=cy-- table= "obd_wave"-- binlog_start_file_name= "mysqlbinlog.000002"-- binlog_start_time= "2017-08-02 20:10:00"

Generate three files under the log directory

# ll-sh13M-rw-r--r-- 1 root root 13m Aug 2 20:38 flashback_cy_20170802_203747.sql / / reverse sql4.0K-rw-r--r-- 1 root root 2.6K Aug 2 20:38 save_data_create_table_cy_20170802_203747.sql 29m-rw-r--r-- 1 root root 29m Aug 2 20:38 save_data_dml_cy_20170802_203747.sql

Find the location where the deletion begins and ends.

Execute a command

# python mysqlbinlog_back.py-- host= "localhost"-- username= "--port=3306-- password="-- schema=cy-- table= "obd_wave"-- binlog_start_file_name= "mysqlbinlog.000002"-- binlog_start_time= "2017-08-02 20:10:00"-- binlog_start_file_position=9664085

Manually delete the contents of the reverse sql after misoperation.

Disadvantages: you can only specify the location of the start, not the location and time of the end.

For the above detailed steps on the use of mysqlbinlog_flashback tools, you do not find it very helpful. If you need to know more, please continue to follow our industry information. I'm sure you'll like it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report