MySQL 8.0 數(shù)據(jù)庫被之前備份文件覆蓋 誤操作恢復(fù) MySQL數(shù)據(jù)庫恢復(fù) MySQL數(shù)據(jù)庫事務(wù)日志恢復(fù)
發(fā)布時間:2023-07-01
客戶在生產(chǎn)環(huán)境導(dǎo)入了2023-03-03的全量備份文件 MySQL誤操作數(shù)據(jù)修復(fù) MySQL數(shù)據(jù)庫修復(fù) MySQL數(shù)據(jù)庫事務(wù)日志恢復(fù)
客戶名稱: 某律師事務(wù)所
數(shù)據(jù)類型: MySQL 8.0.23 on CentOS 7
數(shù)據(jù)庫大小: 900 MB
故障檢測: 誤操作導(dǎo)入了2023-03-03的數(shù)據(jù)庫全量備份文件,覆蓋了當(dāng)前生產(chǎn)數(shù)據(jù)庫yl_user的所有表的數(shù)據(jù)??蛻鬗ySQL實例開啟了log_bin。
系統(tǒng)參數(shù)binlog_expire_logs_seconds默認(rèn)值為2592000,MySQL會自動清理30天之前的binlog文件。
最早的binlog日志文件binlog.000094中只包含自230523 16:23:40以來的所有事務(wù)日志記錄。
幸運(yùn)的是,客戶還有在2023-05-31使用Navicat備份的數(shù)據(jù)庫全量備份文件。
使用Navicat恢復(fù)2023-05-31的全量備份文件,恢復(fù)數(shù)據(jù)庫yl_user從2023-05-31 14:00:12以來的所有增量日志數(shù)據(jù)。
mysqlbinlog --no-defaults --skip-gtids --start-datetime='2023-05-31 14:00:12' -d yl_user binlog.000094 > bin.sql
1)表結(jié)構(gòu)不一致時,mysqlbinlog解析出來的事務(wù)日志導(dǎo)入mysql報錯:
ERROR 1105 (HY000) at line 481577: Unknown error
錯誤日志文件中顯示:
[ERROR] [MY-013146] [Repl] Slave SQL: Column 30 of table 'yl_user.sys_case_management' cannot be converted from
type 'int' to type 'bigint', Error_code: MY-013146
解決方法:
alter table yl_user.sys_case_management modify `entrust_id` int DEFAULT NULL;
2)存在重復(fù)數(shù)據(jù)時,mysqlbinlog解析出來的事務(wù)日志導(dǎo)入mysql報錯:
ERROR 1062 (23000) at line 12747256: Duplicate entry '29' for key 'sys_service.PRIMARY'
錯誤日志文件中顯示:
[ERROR] [MY-010584] [Repl] Slave SQL: Could not execute Write_rows event on table yl_user.sys_case_management;
Duplicate entry '1664168235940970496' for key 'sys_case_management.PRIMARY', Error_code: 1062;
handler error HA_ERR_FOUND_DUPP_KEY; the event's master log FIRST, end_log_pos 247390894,
Error_code: MY-001062
重復(fù)數(shù)據(jù)處理:
delete from sys_service where id = 29;
修復(fù)結(jié)果: 數(shù)據(jù)恢復(fù)率達(dá)99% 客戶非常滿意。將恢復(fù)出來的所有表數(shù)據(jù)導(dǎo)入客戶生產(chǎn)環(huán)境使用沒有任何問題。
在此提醒大家重要的數(shù)據(jù)庫操作之前務(wù)必備份數(shù)據(jù)庫。
-----------------------------------------------------------------------------------------------------------
提供7*24專業(yè)SQL Server數(shù)據(jù)庫修復(fù),MySQL數(shù)據(jù)庫修復(fù),Sybase數(shù)據(jù)庫遠(yuǎn)程及現(xiàn)場技術(shù)支持,Sybase ASE及Sybase SQL Anywhere數(shù)據(jù)庫修復(fù)服務(wù),Oracle數(shù)據(jù)庫修復(fù),PostgreSQL數(shù)據(jù)庫恢復(fù)。
我們可以幫您解決遇到的數(shù)據(jù)庫誤操作、數(shù)據(jù)庫報錯、數(shù)據(jù)庫損壞、被勒索病毒加密等故障問題。
電話:13811580958 (微信),QQ:289965371
We supply technical support for Sybase ASE and Sybase SQL Anywhere, also have many years of experience in recovering data from damanged Sybase devices. Contact us by
Phone: +86 13811580958
Wechat: 13811580958
Email: 289965371@qq.com
掃描以下北京雨翰數(shù)據(jù)恢復(fù)官方微信獲取專業(yè)數(shù)據(jù)庫恢復(fù)服務(wù):
