成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

【MySQL】數(shù)據(jù)庫閃回工具--binlog2sql

[root@wallet01?~]#?cat?/etc/redhat-release?
CentOS?Linux?release?7.5.1804?(Core)?

[root@wallet01?~]#?python?-V
Python?2.7.5

[root@wallet01?~]#?yum?install?-y?python-pip

[root@wallet01?~]#?pip?-V
pip?8.1.2?from?/usr/lib/python2.7/site-packages?(python?2.7)

[root@wallet01?~]#?git?clone?https://github.com/danfengcao/binlog2sql.git
Initialized?empty?Git?repository?in?/root/binlog2sql/.git/
remote:?Enumerating?objects:?323,?done.
remote:?Total?323?(delta?0),?reused?0?(delta?0),?pack-reused?323
Receiving?objects:?100%?(323/323),?151.51?KiB?|?245?KiB/s,?done.
Resolving?deltas:?100%?(170/170),?done.

[root@wallet01?~]#?cd?binlog2sql
[root@wallet01?binlog2sql]#?pip?install?-r?requirements.txt
[root@wallet01?binlog2sql]#?cd?binlog2sql/
[root@wallet01?binlog2sql]#?python?binlog2sql.py?--help
usage:?binlog2sql.py?[-h?HOST]?[-u?USER]?[-p?[PASSWORD?[PASSWORD?...]]]
?????????????????????[-P?PORT]?[--start-file?START_FILE]
?????????????????????[--start-position?START_POS]?[--stop-file?END_FILE]
?????????????????????[--stop-position?END_POS]?[--start-datetime?START_TIME]
?????????????????????[--stop-datetime?STOP_TIME]?[--stop-never]?[--help]
?????????????????????[-d?[DATABASES?[DATABASES?...]]]
?????????????????????[-t?[TABLES?[TABLES?...]]]?[--only-dml]
?????????????????????[--sql-type?[SQL_TYPE?[SQL_TYPE?...]]]?[-K]?[-B]
?????????????????????[--back-interval?BACK_INTERVAL]
?????????????????????
--start-file?--起始解析文件
--stop-file??--終止解析文件
--start-position?--起始解析位置
--stop-position??--終止解析位置
--start-datetime?--起始解析時間,格式'%Y-%m-%d?%H:%M:%S'。
--stop-datetime?--終止解析時間,格式'%Y-%m-%d?%H:%M:%S'。
-d?--僅解析目標(biāo)db的sql
-t?--僅解析目標(biāo)table的sql
--only-dml?--僅解析dml,忽略ddl。
--sql-type?--僅解析指定類型,支持insert,update,delete。
-B?--生成回滾SQL

[root@wallet01?~]#?MySQL?-uroot?-p
Enter?password:?
mysql>?grant?select,replication?client,replication?slave?on?*.*?to?'fb'@'%'?identified?by?'fb@2019';????
Query?OK,?0?rows?affected?(0.05?sec)

mysql>?flush?privileges;
Query?OK,?0?rows?affected?(0.11?sec)

mysql>?show?master?status;
+------------------+----------+--------------+------------------+-------------------+
|?File?????????????|?Position?|?Binlog_Do_DB?|?Binlog_Ignore_DB?|?Executed_Gtid_Set?|
+------------------+----------+--------------+------------------+-------------------+
|?mysql-bin.000008?|??????120?|??????????????|??????????????????|???????????????????|
+------------------+----------+--------------+------------------+-------------------+
1?row?in?set?(0.00?sec)

mysql>?select?now();
+---------------------+
|?now()???????????????|
+---------------------+
|?2019-10-12?17:18:22?|
+---------------------+
1?row?in?set?(0.06?sec)

mysql>?use?gsoa

mysql>?select?count(*)?from?bd_city;
+----------+
|?count(*)?|
+----------+
|??????372?|
+----------+
1?row?in?set?(0.00?sec)

mysql>?begin;
Query?OK,?0?rows?affected?(0.00?sec)

mysql>?delete?from?bd_city;
Query?OK,?372?rows?affected?(0.09?sec)

mysql>?commit;
Query?OK,?0?rows?affected?(0.04?sec)

mysql>?select?count(*)?from?bd_city;
+----------+
|?count(*)?|
+----------+
|????????0?|
+----------+
1?row?in?set?(0.01?sec)

mysql>?select?now();
+---------------------+
|?now()???????????????|
+---------------------+
|?2019-10-12?17:22:26?|
+---------------------+
1?row?in?set?(0.00?sec)

恢復(fù)已提交事務(wù)中刪除的記錄
[root@wallet01?binlog2sql]#?python?binlog2sql.py?-hlocalhost?-P3306?-ufb?-p'fb@2019'?-dgsoa?-tbd_city?\
--start-file='mysql-bin.000008'?--only-dml?--sql-type=delete?\
--start-datetime='2019-10-12?17:18:22'?--stop-datetime='2019-10-12?17:22:26'?>fb.log

[root@wallet01?binlog2sql]#?more?fb.log?
DELETE?FROM?`gsoa`.`bd_city`?WHERE?`status`='1'?AND?`parent_name`='中國'?AND?`code`='110000'?AND?`name`='北京市'?AND?`parent_code`='CN'?LIMIT?1;?
#start?423?end?8756?time?2019-10-12?17:21:26

[root@wallet01?binlog2sql]#?tail?-n?1?fb.log?
DELETE?FROM?`gsoa`.`bd_city`?WHERE?`status`='1'?AND?`parent_name`=''?AND?`code`='CN'?AND?`name`='中國'?AND?`parent_code`=''?LIMIT?1;?
#start?423?end?19319?time?2019-10-12?17:21:26

[root@wallet01?binlog2sql]#?python?binlog2sql.py?-hlocalhost?-P3306?-ufb?-p'fb@2019'?-dgsoa?-tbd_city?\
--start-file='mysql-bin.000008'?--start-position=423?--stop-position=19319?-B?>?rollback.sql

[root@wallet01?binlog2sql]#?more?rollback.sql?|?grep?'北京'
INSERT?INTO?`gsoa`.`bd_city`(`status`,?`parent_name`,?`code`,?`name`,?`parent_code`)?VALUES?('1',?'中國',?'110000',?'北京市',?'CN');?
#start?423?end?8756?time?2019-10-12?17:21:26

[root@wallet01?binlog2sql]#?mysql?-uroot?-p?<?rollback.sql?
Enter?password:?

[root@wallet01?~]#?mysql?-uroot?-p
Enter?password:?
mysql>?use?gsoa

mysql>?select?count(*)?from?bd_city;
+----------+
|?count(*)?|
+----------+
|??????372?|
+----------+
1?row?in?set?(0.00?sec)

網(wǎng)頁標(biāo)題:【MySQL】數(shù)據(jù)庫閃回工具--binlog2sql
網(wǎng)頁URL:http://jinyejixie.com/article0/pshgio.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供靜態(tài)網(wǎng)站搜索引擎優(yōu)化、網(wǎng)站導(dǎo)航ChatGPT、網(wǎng)站建設(shè)定制網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

網(wǎng)站托管運營
南木林县| 嘉祥县| 龙川县| 比如县| 朔州市| 武功县| 克什克腾旗| 固原市| 广昌县| 四平市| 丰城市| 灵石县| 通渭县| 新田县| 泽州县| 长寿区| 多伦县| 锦屏县| 沧州市| 琼结县| 岳阳市| 新宾| 江山市| 黔西| 临海市| 五指山市| 关岭| 柳河县| 凤冈县| 托克逊县| 北安市| 化德县| 潍坊市| 宁陵县| 板桥市| 井陉县| 元氏县| 新民市| 顺义区| 客服| 盐源县|