下载离线包
先在一台能上网的机器下载好离线包
git clone https://github.com/danfengcao/binlog2sql.git
pip3 download -r requirements.txt ./
将依赖包下载到./目录 因为是mysql8.0还需要安装PyMySQL和mysql-replication
pip3 download PyMySQL==0.9.3 ./
pip3 download mysql-replication==0.21 ./
将以上所有依赖包打包同binlog2sql一并上传到离线安装那台机器
离线安装依赖包
cd binlog2sql
pip3 install -r requirements.txt --no-index --find-links=/usr/local/src/binlog2sql
pip3 install PyMySQL-0.9.3-py2.py3-none-any.whl
pip3 install --no-index --find-links=./ mysql-replication-0.21.tar.gz
开始恢复
python3 binlog2sql.py --host 10.10.10.103 -P 3306 -u root -p 123456 -d apaas_business -t act_evt_log --sql-type DELETE --start-file binlog.000021 --start-datetime='2023-06-21 13:50:00' --stop-datetime='2023-06-21 13:55:00' >delete.sql|cat
返回值可以看到
DELETE FROM `apaas_business`.`act_evt_log` WHERE `LOG_NR_`=1 AND `TYPE_`='1' AND `PROC_DEF_ID_`='1' AND `PROC_INST_ID_`='1' AND `EXECUTION_ID_`='1' AND `TASK_ID_`='1' AND `TIME_STAMP_`='2023-06-21 01:53:26' AND `USER_ID_`='1' AND `DATA_` IS NULL AND `LOCK_OWNER_` IS NULL AND `LOCK_TIME_` IS NULL AND `IS_PROCESSED_`=0 LIMIT 1; #start 885 end 1223 time 2023-06-21 14:20:07
确认sql语句没有错就可以拿delete.sql语句恢复了。
标签:误删除,21,pip3,--,离线,binlog2sql,ID From: https://blog.51cto.com/riverxyz/6528556