{"id":185664,"date":"2024-11-10T23:28:22","date_gmt":"2024-11-10T15:28:22","guid":{"rendered":"https:\/\/server.hk\/cnblog\/185664\/"},"modified":"2024-11-10T23:28:23","modified_gmt":"2024-11-10T15:28:23","slug":"%e6%89%8b%e6%ae%98%e5%8f%88%e5%88%aa%e5%ba%ab%e4%ba%86%ef%bc%8cbinlog%e6%95%91%e4%ba%86%e6%88%91%e7%9a%84%e5%91%bd","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/185664\/","title":{"rendered":"\u624b\u6b98\u53c8\u522a\u5eab\u4e86\uff0cbinlog\u6551\u4e86\u6211\u7684\u547d\u2026\u2026"},"content":{"rendered":"<h1 id=\"%e6%89%8b%e6%ae%98%e5%8f%88%e5%88%aa%e5%ba%ab%e4%ba%86%ef%bc%8cbinlog%e6%95%91%e4%ba%86%e6%88%91%e7%9a%84%e5%91%bd-puOsilGzGr\">\u624b\u6b98\u53c8\u522a\u5eab\u4e86\uff0cbinlog\u6551\u4e86\u6211\u7684\u547d\u2026\u2026<\/h1>\n<p>\u5728\u6578\u64da\u5eab\u7ba1\u7406\u4e2d\uff0c\u610f\u5916\u7684\u6578\u64da\u4e1f\u5931\u662f\u8a31\u591a\u958b\u767c\u8005\u548c\u7cfb\u7d71\u7ba1\u7406\u54e1\u6700\u5bb3\u6015\u7684\u60c5\u6cc1\u4e4b\u4e00\u3002\u7121\u8ad6\u662f\u56e0\u70ba\u624b\u6b98\u8aa4\u522a\u4e86\u91cd\u8981\u7684\u6578\u64da\uff0c\u9084\u662f\u56e0\u70ba\u7cfb\u7d71\u6545\u969c\u5c0e\u81f4\u6578\u64da\u640d\u58de\uff0c\u9019\u4e9b\u60c5\u6cc1\u90fd\u53ef\u80fd\u5c0d\u696d\u52d9\u9020\u6210\u56b4\u91cd\u5f71\u97ff\u3002\u7136\u800c\uff0c\u5c0d\u65bc\u4f7f\u7528 MySQL \u7684\u7528\u6236\u4f86\u8aaa\uff0c<strong>binlog\uff08binary log\uff09<\/strong> \u7684\u5b58\u5728\u7121\u7591\u662f\u4e00\u500b\u6551\u547d\u7a3b\u8349\u3002<\/p>\n<h2 id=\"%e4%bb%80%e9%ba%bc%e6%98%af-binlog%ef%bc%9f-puOsilGzGr\">\u4ec0\u9ebc\u662f binlog\uff1f<\/h2>\n<p>binlog \u662f MySQL \u4e2d\u7684\u4e00\u7a2e\u65e5\u8a8c\u6587\u4ef6\uff0c\u7528\u65bc\u8a18\u9304\u6240\u6709\u66f4\u6539\u6578\u64da\u7684\u64cd\u4f5c\u3002\u9019\u4e9b\u64cd\u4f5c\u5305\u62ec\u63d2\u5165\u3001\u66f4\u65b0\u548c\u522a\u9664\u7b49\u3002binlog \u7684\u4e3b\u8981\u76ee\u7684\u662f\u652f\u6301\u6578\u64da\u7684\u6062\u5fa9\u548c\u8907\u88fd\uff0c\u78ba\u4fdd\u6578\u64da\u7684\u4e00\u81f4\u6027\u548c\u5b8c\u6574\u6027\u3002<\/p>\n<h2 id=\"binlog-%e7%9a%84%e5%b7%a5%e4%bd%9c%e5%8e%9f%e7%90%86-puOsilGzGr\">binlog \u7684\u5de5\u4f5c\u539f\u7406<\/h2>\n<p>\u7576 MySQL \u4f3a\u670d\u5668\u57f7\u884c\u4e00\u500b\u66f4\u6539\u6578\u64da\u7684\u64cd\u4f5c\u6642\uff0c\u9019\u500b\u64cd\u4f5c\u6703\u88ab\u5beb\u5165 binlog \u4e2d\u3002\u9019\u4e9b\u65e5\u8a8c\u6587\u4ef6\u53ef\u4ee5\u7528\u4f86\u91cd\u653e\u9019\u4e9b\u64cd\u4f5c\uff0c\u5f9e\u800c\u6062\u5fa9\u5230\u67d0\u500b\u7279\u5b9a\u7684\u6642\u9593\u9ede\u3002binlog \u7684\u683c\u5f0f\u6709\u4e09\u7a2e\uff1a<\/p>\n<ul>\n<li><strong>\u884c\u683c\u5f0f\uff08ROW\uff09<\/strong>\uff1a\u8a18\u9304\u6bcf\u4e00\u884c\u7684\u8b8a\u66f4\uff0c\u9069\u5408\u65bc\u9700\u8981\u7cbe\u78ba\u6062\u5fa9\u7684\u5834\u666f\u3002<\/li>\n<li><strong>\u8a9e\u53e5\u683c\u5f0f\uff08STATEMENT\uff09<\/strong>\uff1a\u8a18\u9304\u57f7\u884c\u7684 SQL \u8a9e\u53e5\uff0c\u9069\u5408\u65bc\u7c21\u55ae\u7684\u6578\u64da\u8b8a\u66f4\u3002<\/li>\n<li><strong>\u6df7\u5408\u683c\u5f0f\uff08MIXED\uff09<\/strong>\uff1a\u6839\u64da\u64cd\u4f5c\u7684\u985e\u578b\u81ea\u52d5\u9078\u64c7\u884c\u683c\u5f0f\u6216\u8a9e\u53e5\u683c\u5f0f\u3002<\/li>\n<\/ul>\n<h2 id=\"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8-binlog-%e9%80%b2%e8%a1%8c%e6%95%b8%e6%93%9a%e6%81%a2%e5%be%a9-puOsilGzGr\">\u5982\u4f55\u4f7f\u7528 binlog \u9032\u884c\u6578\u64da\u6062\u5fa9<\/h2>\n<p>\u5047\u8a2d\u4f60\u4e0d\u5c0f\u5fc3\u522a\u9664\u4e86\u67d0\u500b\u91cd\u8981\u7684\u6578\u64da\u5eab\uff0c\u9019\u6642\u5019\u4f60\u53ef\u4ee5\u901a\u904e binlog \u4f86\u6062\u5fa9\u6578\u64da\u3002\u4ee5\u4e0b\u662f\u6062\u5fa9\u6578\u64da\u7684\u57fa\u672c\u6b65\u9a5f\uff1a<\/p>\n<ol>\n<li>\u9996\u5148\uff0c\u78ba\u4fdd binlog \u529f\u80fd\u5df2\u7d93\u555f\u7528\u3002\u53ef\u4ee5\u901a\u904e\u4ee5\u4e0b\u547d\u4ee4\u6aa2\u67e5\uff1a<\/li>\n<pre><code>SHOW VARIABLES LIKE 'log_bin';<\/code><\/pre>\n<li>\u5982\u679c\u8fd4\u56de\u503c\u70ba ON\uff0c\u5247\u8868\u793a binlog \u5df2\u555f\u7528\u3002<\/li>\n<li>\u63a5\u4e0b\u4f86\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b binlog \u6587\u4ef6\uff1a<\/li>\n<pre><code>SHOW BINARY LOGS;<\/code><\/pre>\n<li>\u9078\u64c7\u5408\u9069\u7684 binlog \u6587\u4ef6\uff0c\u7136\u5f8c\u4f7f\u7528 mysqlbinlog \u5de5\u5177\u4f86\u67e5\u770b\u65e5\u8a8c\u5167\u5bb9\uff1a<\/li>\n<pre><code>mysqlbinlog \/path\/to\/binlog.000001;<\/code><\/pre>\n<li>\u627e\u5230\u9700\u8981\u6062\u5fa9\u7684\u64cd\u4f5c\uff0c\u7136\u5f8c\u5c07\u5176\u91cd\u653e\u5230\u6578\u64da\u5eab\u4e2d\u3002<\/li>\n<\/ol>\n<h2 id=\"binlog-%e7%9a%84%e5%84%aa%e5%8b%a2-puOsilGzGr\">binlog \u7684\u512a\u52e2<\/h2>\n<p>\u4f7f\u7528 binlog \u9032\u884c\u6578\u64da\u6062\u5fa9\u6709\u4ee5\u4e0b\u5e7e\u500b\u512a\u52e2\uff1a<\/p>\n<ul>\n<li><strong>\u9ad8\u6548\u6027<\/strong>\uff1abinlog \u53ea\u8a18\u9304\u6578\u64da\u8b8a\u66f4\uff0c\u80fd\u5920\u5feb\u901f\u5b9a\u4f4d\u548c\u6062\u5fa9\u4e1f\u5931\u7684\u6578\u64da\u3002<\/li>\n<li><strong>\u9748\u6d3b\u6027<\/strong>\uff1a\u53ef\u4ee5\u9078\u64c7\u6062\u5fa9\u5230\u7279\u5b9a\u7684\u6642\u9593\u9ede\uff0c\u6eff\u8db3\u4e0d\u540c\u7684\u696d\u52d9\u9700\u6c42\u3002<\/li>\n<li><strong>\u652f\u6301\u8907\u88fd<\/strong>\uff1abinlog \u662f MySQL \u8907\u88fd\u7684\u57fa\u790e\uff0c\u80fd\u5920\u5be6\u73fe\u4e3b\u5f9e\u6578\u64da\u5eab\u7684\u540c\u6b65\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%b5%90%e8%ab%96-puOsilGzGr\">\u7d50\u8ad6<\/h2>\n<p>\u5728\u6578\u64da\u5eab\u7ba1\u7406\u4e2d\uff0c\u610f\u5916\u7684\u6578\u64da\u4e1f\u5931\u662f\u4e0d\u53ef\u907f\u514d\u7684\uff0c\u4f46\u901a\u904e\u5408\u7406\u4f7f\u7528 binlog\uff0c\u53ef\u4ee5\u6709\u6548\u5730\u6e1b\u5c11\u640d\u5931\u4e26\u5feb\u901f\u6062\u5fa9\u6578\u64da\u3002\u7121\u8ad6\u662f\u958b\u767c\u8005\u9084\u662f\u7cfb\u7d71\u7ba1\u7406\u54e1\uff0c\u90fd\u61c9\u8a72\u719f\u6089 binlog \u7684\u4f7f\u7528\u65b9\u6cd5\uff0c\u4ee5\u5099\u4e0d\u6642\u4e4b\u9700\u3002<\/p>\n<p>\u5982\u679c\u4f60\u6b63\u5728\u5c0b\u627e\u7a69\u5b9a\u7684 <a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a> \u670d\u52d9\uff0cServer.HK \u63d0\u4f9b\u591a\u7a2e\u89e3\u6c7a\u65b9\u6848\uff0c\u5e6b\u52a9\u4f60\u66f4\u597d\u5730\u7ba1\u7406\u548c\u4fdd\u8b77\u4f60\u7684\u6578\u64da\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u624b\u6b98\u53c8\u522a\u5eab\u4e86\uff1f\u5225\u64d4\u5fc3\uff0cbinlog\u6551\u4e86\u6211\u7684\u547d\uff01\u4e86\u89e3\u5982\u4f55\u5229\u7528\u4e8c\u9032\u5236\u65e5\u8a8c\u6062\u5fa9\u6578\u64da\uff0c\u907f\u514d\u707d\u96e3\u6027\u640d\u5931\u3002<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-185664","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/185664","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=185664"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/185664\/revisions"}],"predecessor-version":[{"id":185665,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/185664\/revisions\/185665"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=185664"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=185664"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=185664"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}