溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

MySQL中怎么找回用戶數(shù)據(jù)

發(fā)布時(shí)間:2021-08-04 14:24:11 來源:億速云 閱讀:125 作者:Leah 欄目:數(shù)據(jù)庫

本篇文章給大家分享的是有關(guān)MySQL中怎么找回用戶數(shù)據(jù),小編覺得挺實(shí)用的,因此分享給大家學(xué)習(xí),希望大家閱讀完這篇文章后可以有所收獲,話不多說,跟著小編一起來看看吧。

解決過程

1、首先想到的是直接從定時(shí)備份數(shù)據(jù)里面找回原來的用戶ID,結(jié)果發(fā)現(xiàn)系統(tǒng)只備份了十天的記錄,而工作流系統(tǒng)上顯示銷售C只有8月3號(hào)以后的流程記錄,距今已經(jīng)40多天,從自動(dòng)備份的數(shù)據(jù)里已經(jīng)無法恢復(fù)。

2、所以,只能從數(shù)據(jù)庫的二進(jìn)制記錄里分析了。進(jìn)入MySQL數(shù)據(jù)存放的目錄:

MySQL中怎么找回用戶數(shù)據(jù)

3、通過分析文件修改時(shí)間,得知?jiǎng)h除操作的動(dòng)作在mysql-bin.000014文件里面記錄。

4、因?yàn)槿罩疚募嵌M(jìn)制的,所以導(dǎo)出日志為sql文件:

mysqlbinlog --no-defaults mysql-bin.000014 > workflow_operator.sql

5、日志記錄比較大,導(dǎo)出后有132M,壓縮打包文件并下載到本地,只有15.2M

tar -czvf workflow_operator.tar.gz workflow_operator.sql

6、在本地使用文本工具,查找所有的刪除用戶的操作:

***定位刪除銷售C的動(dòng)作在127766行(雖然日志記錄行數(shù)比較多,但是刪除用戶的動(dòng)作比較少,所以好排查)

MySQL中怎么找回用戶數(shù)據(jù)

7、用戶ID找到了,所幸的是,因?yàn)橹粍h除了用戶,沒有刪除流程數(shù)據(jù)(因?yàn)榱鞒虜?shù)據(jù)是要存檔的),所以只要把銷售C的舊流程數(shù)據(jù)user_id換成新的user_id就可以了,流程表比較多,通過體力勞動(dòng),找出有舊ID的表,然后再使用update語句一起更新,終于找回了所有數(shù)據(jù):

(***四位由于涉及隱私,使用XXX代替)

update flow_fr_borrow set user_id = 'e76cb8bccaf74f32b94d17f74437xxxx' where user_id = '66adfd032ccf428d9e20e864f729xxxx'; update flow_fr_cost set user_id = 'e76cb8bccaf74f32b94d17f74437xxxx' where user_id = '66adfd032ccf428d9e20e864f729xxxx'; update flow_fr_fixedasset set user_id = 'e76cb8bccaf74f32b94d17f74437xxxx' where user_id = '66adfd032ccf428d9e20e864f729xxxx'; update flow_fr_house_lease set user_id = 'e76cb8bccaf74f32b94d17f74437xxxx' where user_id = '66adfd032ccf428d9e20e864f729xxxx'; update flow_fr_purchase set user_id = 'e76cb8bccaf74f32b94d17f74437xxxx' where user_id = '66adfd032ccf428d9e20e864f729xxxx'; update flow_fr_travel set user_id = 'e76cb8bccaf74f32b94d17f74437xxxx' where user_id = '66adfd032ccf428d9e20e864f729xxxx'; update flow_hr_positive set user_id = 'e76cb8bccaf74f32b94d17f74437xxxx' where user_id = '66adfd032ccf428d9e20e864f729xxxx'; update flow_pr_equip_borrow_sale set user_id = 'e76cb8bccaf74f32b94d17f74437xxxx' where user_id = '66adfd032ccf428d9e20e864f729xxxx'; update flow_pr_equip_return set user_id = 'e76cb8bccaf74f32b94d17f74437xxxx' where user_id = '66adfd032ccf428d9e20e864f729xxxx'; update flow_sa_tepe set user_id = 'e76cb8bccaf74f32b94d17f74437xxxx' where user_id = '66adfd032ccf428d9e20e864f729xxxx'; update flow_sa_safore set user_id = 'e76cb8bccaf74f32b94d17f74437xxxx' where user_id = '66adfd032ccf428d9e20e864f729xxxx'; update flow_sa_authorize set user_id = 'e76cb8bccaf74f32b94d17f74437xxxx' where user_id = '66adfd032ccf428d9e20e864f729xxxx'; update flow_sa_business set user_id = 'e76cb8bccaf74f32b94d17f74437xxxx' where user_id = '66adfd032ccf428d9e20e864f729xxxx'; update flow_hr_trial set sel_user_id = 'e76cb8bccaf74f32b94d17f74437xxxx' where sel_user_id = '66adfd032ccf428d9e20e864f729xxxx' ; update wf_hist_order set creator = 'e76cb8bccaf74f32b94d17f74437xxxx' where creator = '66adfd032ccf428d9e20e864f729xxxx'; update wf_hist_task set operator = 'e76cb8bccaf74f32b94d17f74437xxxx' where operator = '66adfd032ccf428d9e20e864f729xxxx'; update wf_order set creator = 'e76cb8bccaf74f32b94d17f74437xxxx' where creator = '66adfd032ccf428d9e20e864f729xxxx'; update wf_hist_task_actor set actor_Id = 'e76cb8bccaf74f32b94d17f74437xxxx' where actor_Id = '66adfd032ccf428d9e20e864f729xxxx';

以上就是MySQL中怎么找回用戶數(shù)據(jù),小編相信有部分知識(shí)點(diǎn)可能是我們?nèi)粘9ぷ鲿?huì)見到或用到的。希望你能通過這篇文章學(xué)到更多知識(shí)。更多詳情敬請(qǐng)關(guān)注億速云行業(yè)資訊頻道。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI