{"id":6008,"date":"2024-11-14T11:37:18","date_gmt":"2024-11-14T03:37:18","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6008\/"},"modified":"2024-11-14T11:37:18","modified_gmt":"2024-11-14T03:37:18","slug":"mysql%e5%a6%82%e4%bd%95%e5%bc%80%e5%90%afbinlog","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6008\/","title":{"rendered":"mysql\u5982\u4f55\u5f00\u542fbinlog"},"content":{"rendered":"<blockquote><p>\n  mysql\u5f00\u542f\u4e8c\u8fdb\u5236\u65e5\u5fd7\uff08binlog\uff09\u65b9\u6cd5\uff1a\u4fee\u6539\u914d\u7f6e\u6587\u4ef6 my.cnf\uff0c\u6dfb\u52a0 binlog-do-db \u548c binlog-ignore-db \u53c2\u6570\u3002\u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177\u8fde\u63a5\u5230 mysql \u6570\u636e\u5e93\uff0c\u6267\u884c set global binlog_format=row;\u3001set global binlog-do-db = \u548c set global binlog-ignore-db = \u547d\u4ee4\u3002\u6267\u884c commit; \u4fdd\u5b58\u8bbe\u7f6e\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202406\/12\/2024061214542630639.jpg\" class=\"aligncenter\" title=\"mysql\u5982\u4f55\u5f00\u542fbinlog\u63d2\u56fe\" alt=\"mysql\u5982\u4f55\u5f00\u542fbinlog\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5f00\u542f MySQL binlog<\/strong><\/p>\n<p><strong>\u5f00\u542f\u65b9\u6cd5\uff1a<\/strong><\/p>\n<p>\u5728 MySQL \u4e2d\u542f\u7528\u4e8c\u8fdb\u5236\u65e5\u5fd7\uff08binlog\uff09\u975e\u5e38\u7b80\u5355\uff0c\u53ef\u4ee5\u901a\u8fc7\u4fee\u6539 MySQL \u914d\u7f6e\u6587\u4ef6 my.cnf \u6216\u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177\u6765\u5b9e\u73b0\u3002<\/p>\n<p><strong>\u4fee\u6539 my.cnf \u914d\u7f6e\u6587\u4ef6\uff1a<\/strong><\/p>\n<ol>\n<li>\u6253\u5f00 my.cnf \u6587\u4ef6\uff0c\u901a\u5e38\u4f4d\u4e8e \/etc\/\/ \u76ee\u5f55\u4e0b\u3002<\/li>\n<li>\n<p>\u5728 [mysqld] \u90e8\u5206\u6dfb\u52a0\u4ee5\u4e0b\u8bed\u53e5\uff1a<\/p>\n<pre>binlog-do-db = &lt;\u8981\u8bb0\u5f55\u66f4\u6539\u7684\u6570\u636e\u5e93&gt;\nbinlog-ignore-db = &lt;\u8981\u5ffd\u7565\u7684\u6570\u636e\u5e93&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li>\u4fdd\u5b58\u5e76\u5173\u95ed\u6587\u4ef6\u3002<\/li>\n<\/ol>\n<p><strong>\u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177\uff1a<\/strong><\/p>\n<ol>\n<li>\n<p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fde\u63a5\u5230 MySQL \u6570\u636e\u5e93\uff1a<\/p>\n<pre>mysql -u root -p<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li>\u8f93\u5165 MySQL root \u7528\u6237\u7684\u5bc6\u7801\u3002<\/li>\n<li>\n<p>\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u542f\u7528 binlog\uff1a<\/p>\n<pre>SET GLOBAL binlog_format=ROW;\nSET GLOBAL binlog-do-db = &lt;\u8981\u8bb0\u5f55\u66f4\u6539\u7684\u6570\u636e\u5e93&gt;;\nSET GLOBAL binlog-ignore-db = &lt;\u8981\u5ffd\u7565\u7684\u6570\u636e\u5e93&gt;;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li>\n<p>\u4fdd\u5b58\u8bbe\u7f6e\uff1a<\/p>\n<pre>COMMIT;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<\/ol>\n<p><strong>\u8be6\u7ec6\u8bf4\u660e\uff1a<\/strong><\/p>\n<ul>\n<li> <strong>binlog-do-db\uff1a<\/strong>\u6307\u5b9a\u8981\u8bb0\u5f55\u66f4\u6539\u7684\u6570\u636e\u5e93\uff0c\u591a\u4e2a\u6570\u636e\u5e93\u4e4b\u95f4\u7528\u9017\u53f7\u5206\u9694\u3002<\/li>\n<li> <strong>binlog-ignore-db\uff1a<\/strong>\u6307\u5b9a\u8981\u5ffd\u7565\u7684\u6570\u636e\u5e93\uff0c\u591a\u4e2a\u6570\u636e\u5e93\u4e4b\u95f4\u7528\u9017\u53f7\u5206\u9694\u3002<\/li>\n<li> <strong>binlog_format=ROW\uff1a<\/strong>\u6307\u5b9a binlog \u683c\u5f0f\uff0c\u672c\u6587\u63a8\u8350\u4f7f\u7528 ROW \u683c\u5f0f\uff0c\u56e0\u4e3a\u5b83\u8bb0\u5f55\u4e86\u6570\u636e\u884c\u7684\u5b9e\u9645\u66f4\u6539\u3002<\/li>\n<\/ul>\n<p><strong>\u6ce8\u610f\u4e8b\u9879\uff1a<\/strong><\/p>\n<ul>\n<li>\u5728\u542f\u7528 binlog \u4e4b\u524d\uff0c\u8bf7\u786e\u4fdd MySQL \u670d\u52a1\u5df2\u505c\u6b62\u3002<\/li>\n<li>\u542f\u7528 binlog \u53ef\u80fd\u4f1a\u589e\u52a0 MySQL \u7684\u5f00\u9500\u548c\u78c1\u76d8\u7a7a\u95f4\u4f7f\u7528\u3002<\/li>\n<li>\u5b9a\u671f\u7ef4\u62a4 binlog \u4ee5\u907f\u514d\u6587\u4ef6\u8fc7\u5927\u5e76\u5f71\u54cd\u6027\u80fd\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u5f00\u542fbinlog\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>mysql\u5f00\u542f\u4e8c\u8fdb\u5236\u65e5\u5fd7\uff08binlog\uff09\u65b9\u6cd5\uff1a\u4fee\u6539\u914d\u7f6e\u6587\u4ef6 my.cnf\uff0c\u6dfb\u52a0 binlog-do-db \u548c binlog-ignore-db \u53c2\u6570\u3002\u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177\u8fde\u63a5\u5230 mysql \u6570\u636e\u5e93\uff0c\u6267\u884c set global binlog_format=row;\u3001set global binlog-do-db = \u548c set global binlog-ignore-db = \u547d\u4ee4\u3002\u6267\u884c commit; \u4fdd\u5b58\u8bbe\u7f6e\u3002 \u5982\u4f55\u5f00\u542f MySQL binlog \u5f00\u542f\u65b9\u6cd5\uff1a \u5728 MySQL \u4e2d\u542f\u7528\u4e8c\u8fdb\u5236\u65e5\u5fd7\uff08binlog\uff09\u975e\u5e38\u7b80\u5355\uff0c\u53ef\u4ee5\u901a\u8fc7\u4fee\u6539 MySQL \u914d\u7f6e\u6587\u4ef6 my.cnf \u6216\u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177\u6765\u5b9e\u73b0\u3002 \u4fee\u6539 my.cnf \u914d\u7f6e\u6587\u4ef6\uff1a \u6253\u5f00 my.cnf \u6587\u4ef6\uff0c\u901a\u5e38\u4f4d\u4e8e \/etc\/\/ \u76ee\u5f55\u4e0b\u3002 \u5728 [mysqld] \u90e8\u5206\u6dfb\u52a0\u4ee5\u4e0b\u8bed\u53e5\uff1a binlog-do-db = &lt;\u8981\u8bb0\u5f55\u66f4\u6539\u7684\u6570\u636e\u5e93&gt; binlog-ignore-db = &lt;\u8981\u5ffd\u7565\u7684\u6570\u636e\u5e93&gt; \u767b\u5f55\u540e\u590d\u5236 \u4fdd\u5b58\u5e76\u5173\u95ed\u6587\u4ef6\u3002 \u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177\uff1a \u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fde\u63a5\u5230 MySQL [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-6008","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6008","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=6008"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6008\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6008"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6008"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6008"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}