日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
MySQL數(shù)據(jù)庫操作刪除記錄日志詳解 (mysql數(shù)據(jù)庫中操作刪除記錄日志)

MySQL是一種強(qiáng)大的關(guān)系型數(shù)據(jù)庫管理系統(tǒng),它的應(yīng)用范圍廣泛,用于許多類型的網(wǎng)絡(luò)應(yīng)用程序,包括網(wǎng)站、游戲和軟件應(yīng)用。然而,在MySQL數(shù)據(jù)庫中,刪除某些記錄時(shí)可能會(huì)導(dǎo)致數(shù)據(jù)丟失,這是每個(gè)數(shù)據(jù)庫管理員必須考慮的事情。為了避免數(shù)據(jù)丟失,并提高M(jìn)ySQL數(shù)據(jù)庫管理員的日常操作效率,本文將為您詳細(xì)介紹MySQL數(shù)據(jù)庫操作刪除記錄日志。

創(chuàng)新互聯(lián)建站堅(jiān)持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:成都做網(wǎng)站、成都網(wǎng)站建設(shè)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時(shí)代的三江侗網(wǎng)站設(shè)計(jì)、移動(dòng)媒體設(shè)計(jì)的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!

1. 什么是MySQL數(shù)據(jù)庫操作刪除記錄日志

MySQL數(shù)據(jù)庫刪除記錄日志是一種記錄數(shù)據(jù)庫刪除操作的機(jī)制。它用于記錄在任何時(shí)間點(diǎn)MySQL數(shù)據(jù)庫中任何表中的刪除操作。這是一種非常重要的機(jī)制,因?yàn)樗梢杂糜诨謴?fù)意外刪除的數(shù)據(jù)。 通過使用刪除記錄日志,您可以確保在MySQL數(shù)據(jù)庫中的數(shù)據(jù)更加安全,同時(shí)提高M(jìn)ySQL數(shù)據(jù)庫管理員的操作效率和精度。

2. MySQL數(shù)據(jù)庫操作刪除記錄日志的優(yōu)點(diǎn)

MySQL數(shù)據(jù)庫操作刪除記錄日志的一個(gè)更大的優(yōu)點(diǎn)是,它為MySQL數(shù)據(jù)庫管理員提供了一種安全保護(hù)機(jī)制。如果在MySQL數(shù)據(jù)庫中誤刪除了某些記錄,可以通過日志輕松地恢復(fù)這些記錄。同時(shí),這種機(jī)制還可以用于監(jiān)視刪除操作,從而更好地了解MySQL數(shù)據(jù)庫中的數(shù)據(jù)操作情況。

3. 如何啟用MySQL數(shù)據(jù)庫操作刪除記錄日志

要啟用MySQL數(shù)據(jù)庫操作刪除記錄日志,您必須進(jìn)行以下步驟:

3.1 修改my.cnf文件

在MySQL服務(wù)器上找到“my.cnf”文件。在打開該文件之前,首先需要備份該文件以避免任何不必要的損失。打開my.cnf文件并找到以下參數(shù):

log-bin = /var/log/mysql/mysql-bin.log

expire_logs_days = 10

max_binlog_size = 100M

3.2 重啟MySQL服務(wù)器

要使更改生效,必須重新啟動(dòng)MySQL服務(wù)器。要執(zhí)行此操作,只需在控制臺(tái)運(yùn)行以下命令:

sudo service mysql restart

3.3 日志查看

要查看在MySQL數(shù)據(jù)庫中執(zhí)行的刪除操作,只需打開MySQL控制臺(tái)并執(zhí)行以下命令:

mysql> show binlog events\G;

4.

MySQL數(shù)據(jù)庫操作刪除記錄日志是一種非常實(shí)用的工具,用于記錄在使用MySQL數(shù)據(jù)庫時(shí)進(jìn)行的刪除操作。它為MySQL數(shù)據(jù)庫管理員提供了安全保護(hù)機(jī)制,并可以用于恢復(fù)任何意外刪除的記錄。要啟用MySQL數(shù)據(jù)庫操作刪除記錄日志,只需完成幾個(gè)簡單的步驟。通過使用這種機(jī)制,MySQL數(shù)據(jù)庫管理員可以更加合理地管理MySQL數(shù)據(jù)庫,并提高操作效率和精度。

相關(guān)問題拓展閱讀:

  • 為什么MySQL中刪除查詢?nèi)罩竞湾e(cuò)誤日志都是用圖中紅框中的那個(gè)代碼,怎么區(qū)分?

為什么MySQL中刪除查詢?nèi)罩竞湾e(cuò)誤日志都是用圖中紅框中的那個(gè)代碼,怎么區(qū)分?

flush-logs 刪棗咐除磨巖棚所有的日志

flush-slow-log 刪除慢查詢瞎則日志

看書怎么區(qū)分,去實(shí)踐,去下載mysql

MySQL 8.0 重新定義了錯(cuò)誤日志輸出和過濾,改善了原來臃腫并且可讀性很差的錯(cuò)誤日志。比如增加了 ON 輸出,在原來的日志后面以序號(hào)以及 ON 后綴的方式展示。比如我機(jī)器上的 MySQL 以 ON 保存的錯(cuò)誤日志 mysqld.log.00.json:# jq . mysqld.log.00.json{  “l(fā)og_type”: 1,  “prio”: 1,  “err_code”: 12592,  “subsystem”: “InnoDB”模碧侍,  “msg”: “Operating system error number 2 in a file operation.”,  “time”: “T08:16:12.111808Z”,  “thread”: 8,  “err_symbol”: “ER_IB_MSG_767”,  “SQL_state”: “HY000”,  “l(fā)abel”: “Error”}{  “l(fā)og_type”: 1,  “prio”: 1,  “err_code”: 12593,  “subsystem”: “InnoDB”,  “msg”: “The error means the system cannot find the path specified.”,  “time”: “T08:16:12.111915Z”,  “thread”: 8,  “err_symbol”: “ER_IB_MSG_768”,  “SQL_state”: “HY000”,  “l(fā)abel”: “Error”}{  “l(fā)og_type”: 1,  “prio”: 1,  “err_code”: 12216,  “subsystem”: “InnoDB”,  “msg”: “Cannot open datafile for read-only: ‘./ytt2/a.ibd’ OS error: 71”,  “time”: “T08:16:12.111933Z”,  “thread”旦吵: 8,  “err_symbol”: “ER_IB_MSG_391”,  “SQL_state”: “HY000”,  “l(fā)abel”: “Error”}以 ON 輸出錯(cuò)誤日志后可讀性和可操作性增強(qiáng)了許多。這里可以慧嘩用 Linux 命令 jq 或者把這個(gè)字串 COPY 到其他解析 ON 的工具方便處理。只想非常快速的拿出錯(cuò)誤信息,忽略其他信息。#  jq   ‘.msg’ mysqld.log.00.json”O(jiān)perating system error number 2 in a file operation.””The error means the system cannot find the path specified.””Cannot open datafile for read-only: ‘./ytt2/a.ibd’ OS error: 71″”Cannot calculate statistics for table `ytt2`.`a` because the .ibd file is missing. Please refer to for how to resolve the issue.””Cannot calculate statistics for table `ytt2`.`a` because the .ibd file is missing. Please refer to for how to resolve the issue.”使用 ON 輸出的前提是安裝 ON 輸出部件。

INSTALL COMPONENT ‘

完了在設(shè)置變量 SET GLOBAL log_error_services = ‘log_filter_internal; log_sink_json’;

格式為:過濾規(guī)則;日志輸出;日志輸出;查看安裝好的部件mysql> select * from mysql.component;++——++| component_id | component_group_id | component_urn|++——++||    1 ||++——++3 rows in set (0.00 sec)

現(xiàn)在設(shè)置 ON 輸出,輸出到系統(tǒng)日志的同時(shí)輸出到 ON 格式日志。mysql> SET persist log_error_services = ‘log_filter_internal; log_sink_internal; log_sink_json’;Query OK, 0 rows affected (0.00 sec)

來測試一把。我之前已經(jīng)把表 a 物理文件刪掉了。mysql> select * from a;ERROR 1812 (HY000): Tablespace is missing for table `ytt2`.`a`.

現(xiàn)在錯(cuò)誤日志里有 5 條記錄。

# tailf  mysqld.log

T08:16:12.111808Z 8 Operating system error number 2 in a file operation.

T08:16:12.111915Z 8 The error means the system cannot find the path specified.

T08:16:12.111933Z 8 Cannot open datafile for read-only: ‘./ytt2/a.ibd’ OS error: 71

T08:16:12.112227Z 8 Cannot calculate statistics for table `ytt2`.`a` because the .ibd file is missing. Please refer to for how to resolve the issue.

T08:16:14.902617Z 8 Cannot calculate statistics for table `ytt2`.`a` because the .ibd file is missing. Please refer to for how to resolve the issue.

ON 日志里也有 5 條記錄。

# tailf mysqld.log.00.json

{ “l(fā)og_type” : 1, “prio” : 1, “err_code” : 12592, “subsystem” : “InnoDB”, “msg” : “Operating system error number 2 in a file operation.”, “time” : “T08:16:12.111808Z”, “thread” : 8, “err_symbol” : “ER_IB_MSG_767”, “SQL_state” : “HY000”, “l(fā)abel” : “Error” }

{ “l(fā)og_type” : 1, “prio” : 1, “err_code” : 12593, “subsystem” : “InnoDB”, “msg” : “The error means the system cannot find the path specified.”, “time” : “T08:16:12.111915Z”, “thread” : 8, “err_symbol” : “ER_IB_MSG_768”, “SQL_state” : “HY000”, “l(fā)abel” : “Error” }

{ “l(fā)og_type” : 1, “prio” : 1, “err_code” : 12216, “subsystem” : “InnoDB”, “msg” : “Cannot open datafile for read-only: ‘./ytt2/a.ibd’ OS error: 71”, “time” : “T08:16:12.111933Z”, “thread” : 8, “err_symbol” : “ER_IB_MSG_391”, “SQL_state” : “HY000”, “l(fā)abel” : “Error” }

{ “l(fā)og_type” : 1, “prio” : 2, “err_code” : 12023, “subsystem” : “InnoDB”, “msg” : “Cannot calculate statistics for table `ytt2`.`a` because the .ibd file is missing. Please refer to for how to resolve the issue.”, “time” : “T08:16:12.112227Z”, “thread” : 8, “err_symbol” : “ER_IB_MSG_224”, “SQL_state” : “HY000”, “l(fā)abel” : “Warning” }

{ “l(fā)og_type” : 1, “prio” : 2, “err_code” : 12023, “subsystem” : “InnoDB”, “msg” : “Cannot calculate statistics for table `ytt2`.`a` because the .ibd file is missing. Please refer to for how to resolve the issue.”, “time” : “T08:16:14.902617Z”, “thread” : 8, “err_symbol” : “ER_IB_MSG_224”, “SQL_state” : “HY000”, “l(fā)abel” : “Warning” }

那可能有人就問了,這有啥意義呢?只是把格式變了,過濾的規(guī)則我看還是沒變。那我們現(xiàn)在給第二條日志輸出加過濾規(guī)則先把過濾日志的部件安裝起來

INSTALL COMPONENT ‘

mysql> SET persist log_error_services = ‘log_filter_internal; log_sink_internal; log_filter_dragnet;log_sink_json’;

Query OK, 0 rows affected (0.00 sec)

只保留 error,其余的一律過濾掉。SET GLOBAL dragnet.log_error_filter_rules = ‘IF prio>=WARNING THEN drop.’;

檢索一張誤刪的表mysql> select * from a;ERROR 1812 (HY000): Tablespace is missing for table `ytt2`.`a`.

查看錯(cuò)誤日志和 ON 錯(cuò)誤日志發(fā)現(xiàn)錯(cuò)誤日志里有一條 Warning,ON 錯(cuò)誤日志里的被過濾掉了。T08:22:32.978728Z 8 Cannot calculate statistics for table `ytt2`.`a` because the .ibd file is missing. Please refer to for how to resolve the issue.

再舉個(gè)例子,每 60 秒只允許記錄一個(gè) Warning 事件mysql> SET GLOBAL dragnet.log_error_filter_rules = ‘IF prio==WARNING THEN throttle 1/60.’;Query OK, 0 rows affected (0.00 sec)

多次執(zhí)行mysql> select * from b;ERROR 1812 (HY000): Tablespace is missing for table `ytt2`.`b`.mysql> select * from b;ERROR 1812 (HY000): Tablespace is missing for table `ytt2`.`b`.mysql> select * from b;ERROR 1812 (HY000): Tablespace is missing for table `ytt2`.`b`.

現(xiàn)在錯(cuò)誤日志里有三條 warning 信息

T08:49:06.820235Z 8 Cannot calculate statistics for table `ytt2`.`b` because the .ibd file is missing. Please refer to for how to resolve the issue.

T08:49:31.455907Z 8 Cannot calculate statistics for table `ytt2`.`b` because the .ibd file is missing. Please refer to for how to resolve the issue.

T08:50:00.430867Z 8 Cannot calculate statistics for table `ytt2`.`b` because the .ibd file is missing. Please refer to for how to resolve the issue.

mysqld.log.00.json 只有一條{ “l(fā)og_type” : 1, “prio” : 2, “err_code” : 12023, “subsystem” : “InnoDB”, “msg” : “Cannot calculate statistics for table `ytt2`.`b` because the .ibd file is missing. Please refer to for how to resolve the issue.”, “time” : “T08:49:06.820235Z”, “thread” : 8, “err_symbol” : “ER_IB_MSG_224”, “SQL_state” : “HY000”, “and_n_more” : 3, “l(fā)abel” : “Warning” }

總結(jié),我這里簡單介紹了下 MySQL 8.0 的錯(cuò)誤日志過濾以及 ON 輸出。MySQL 8.0 的component_log_filter_dragnet 部件過濾規(guī)則非常靈活,可以參考手冊(cè),根據(jù)它提供的語法寫出自己的過濾掉的日志輸出。

關(guān)于mysql數(shù)據(jù)庫中操作刪除記錄日志的介紹到此就結(jié)束了,不知道你從中找到你需要的信息了嗎 ?如果你還想了解更多這方面的信息,記得收藏關(guān)注本站。

成都服務(wù)器租用選創(chuàng)新互聯(lián),先試用再開通。
創(chuàng)新互聯(lián)(www.cdcxhl.com)提供簡單好用,價(jià)格厚道的香港/美國云服務(wù)器和獨(dú)立服務(wù)器。物理服務(wù)器托管租用:四川成都、綿陽、重慶、貴陽機(jī)房服務(wù)器托管租用。


文章名稱:MySQL數(shù)據(jù)庫操作刪除記錄日志詳解 (mysql數(shù)據(jù)庫中操作刪除記錄日志)
文章出自:http://www.dlmjj.cn/article/dpiieee.html