{"id":5518,"date":"2024-11-14T10:19:17","date_gmt":"2024-11-14T02:19:17","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5518\/"},"modified":"2024-11-14T10:19:17","modified_gmt":"2024-11-14T02:19:17","slug":"mysql%e8%a1%a8%e5%88%a0%e9%99%a4%e4%ba%86%e6%80%8e%e4%b9%88%e6%81%a2%e5%a4%8d","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5518\/","title":{"rendered":"mysql\u8868\u5220\u9664\u4e86\u600e\u4e48\u6062\u590d"},"content":{"rendered":"<blockquote><p>\n  mysql \u8868\u8bef\u5220\u6062\u590d\u6709\u4e24\u79cd\u65b9\u6cd5\uff1a\u4e8c\u8fdb\u5236\u65e5\u5fd7\u6062\u590d\uff1a\u786e\u8ba4\u5f00\u542f\u4e8c\u8fdb\u5236\u65e5\u5fd7\u4f7f\u7528 mysqlbinlog \u627e\u51fa\u5220\u9664\u8868\u7684\u4e8c\u8fdb\u5236\u65e5\u5fd7\u5c06\u4e8c\u8fdb\u5236\u65e5\u5fd7\u5bfc\u5165\u6216\u91cd\u65b0\u5e94\u7528\u6570\u636e\u6587\u4ef6\u6062\u590d\uff1a\u627e\u5230\u88ab\u5220\u8868\u7684 .frm\u3001.ibd \u548c .myi \u6587\u4ef6\u521b\u5efa\u76f8\u540c\u7ed3\u6784\u7684\u65b0\u8868\u505c\u6b62 mysql \u5e76\u66ff\u6362\u65b0\u8868\u7684\u6587\u4ef6\u4e3a\u65e7\u6587\u4ef6\u542f\u52a8 mysql \u5e76\u68c0\u67e5\u65b0\u8868\u6570\u636e\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/29\/2024052907302843784.jpg\" class=\"aligncenter\" title=\"mysql\u8868\u5220\u9664\u4e86\u600e\u4e48\u6062\u590d\u63d2\u56fe\" alt=\"mysql\u8868\u5220\u9664\u4e86\u600e\u4e48\u6062\u590d\u63d2\u56fe\" \/><\/p>\n<p><strong>MySQL \u8868\u8bef\u5220\u6062\u590d\u65b9\u6cd5<\/strong><\/p>\n<p>\u5f53 MySQL \u8868\u88ab\u610f\u5916\u5220\u9664\u65f6\uff0c\u6709\u4e24\u79cd\u65b9\u6cd5\u53ef\u4ee5\u5c1d\u8bd5\u6062\u590d\uff1a<\/p>\n<p><strong>\u65b9\u6cd5\u4e00\uff1a\u4e8c\u8fdb\u5236\u65e5\u5fd7 (binlog)<\/strong><\/p>\n<ol>\n<li>\u786e\u8ba4\u670d\u52a1\u5668\u542f\u7528\u4e8c\u8fdb\u5236\u65e5\u5fd7\u8bb0\u5f55\u3002<\/li>\n<li>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u627e\u51fa\u5220\u9664\u8868\u7684\u4e8c\u8fdb\u5236\u65e5\u5fd7\uff1a<\/li>\n<\/ol>\n<pre>mysqlbinlog --start-position=NNN --stop-position=MMM --database=&lt;database_name&gt; &lt;log_file&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5176\u4e2d\uff0cNNN \u548c MMM \u662f\u5220\u9664\u64cd\u4f5c\u53d1\u751f\u524d\u540e\u7684\u4e8c\u8fdb\u5236\u65e5\u5fd7\u4f4d\u7f6e\u3002<\/p>\n<p><span>\u70b9\u51fb\u4e0b\u8f7d<\/span>\u201c\u201d\uff1b<\/p>\n<ol>\n<li>\u5c06\u627e\u5230\u7684\u4e8c\u8fdb\u5236\u65e5\u5fd7\u5bfc\u5165\u53e6\u4e00\u4e2a\u6570\u636e\u5e93\u5b9e\u4f8b\u6216\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u91cd\u65b0\u5e94\u7528\uff1a<\/li>\n<\/ol>\n<pre>mysql --binlog=&lt;log_file&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u65b9\u6cd5\u4e8c\uff1a\u6570\u636e\u6587\u4ef6\u6062\u590d<\/strong><\/p>\n<ol>\n<li>\u627e\u5230\u88ab\u5220\u9664\u8868\u7684 .frm\u3001.ibd \u548c .MYI \u6587\u4ef6\uff0c\u5b83\u4eec\u901a\u5e38\u4f4d\u4e8e MySQL \u6570\u636e\u76ee\u5f55\u7684 \/data\/ \u5b50\u76ee\u5f55\u4e2d\u3002<\/li>\n<li>\u5728\u53e6\u4e00\u4e2a MySQL \u5b9e\u4f8b\u4e2d\uff0c\u521b\u5efa\u4e0e\u88ab\u5220\u9664\u8868\u7ed3\u6784\u76f8\u540c\u7684\u65b0\u8868\u3002<\/li>\n<li>\u505c\u6b62 MySQL \u5b9e\u4f8b\u5e76\u66ff\u6362\u65b0\u8868\u7684 .frm\u3001.ibd \u548c .MYI \u6587\u4ef6\u4e3a\u5df2\u5220\u9664\u8868\u7684\u76f8\u5e94\u6587\u4ef6\u3002<\/li>\n<li>\u542f\u52a8 MySQL \u5b9e\u4f8b\u5e76\u68c0\u67e5\u65b0\u8868\u662f\u5426\u5305\u542b\u5df2\u5220\u9664\u8868\u7684\u6570\u636e\u3002<\/li>\n<\/ol>\n<p><strong>\u6ce8\u610f\u4e8b\u9879\uff1a<\/strong><\/p>\n<ul>\n<li>\u4ee5\u4e0a\u65b9\u6cd5\u4ec5\u9002\u7528\u4e8e\u8868\u7684\u903b\u8f91\u5220\u9664\uff0c\u7269\u7406\u5220\u9664\u65e0\u6cd5\u6062\u590d\u3002<\/li>\n<li>\u4e8c\u8fdb\u5236\u65e5\u5fd7\u6062\u590d\u9700\u8981\u542f\u7528\u4e8c\u8fdb\u5236\u65e5\u5fd7\u8bb0\u5f55\u3002<\/li>\n<li>\u6570\u636e\u6587\u4ef6\u6062\u590d\u9700\u8981\u786e\u4fdd\u5df2\u5220\u9664\u8868\u7684\u6587\u4ef6\u672a\u88ab\u8986\u76d6\u6216\u4fee\u6539\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u8868\u5220\u9664\u4e86\u600e\u4e48\u6062\u590d\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 \u8868\u8bef\u5220\u6062\u590d\u6709\u4e24\u79cd\u65b9\u6cd5\uff1a\u4e8c\u8fdb\u5236\u65e5\u5fd7\u6062\u590d\uff1a\u786e\u8ba4\u5f00\u542f\u4e8c\u8fdb\u5236\u65e5\u5fd7\u4f7f\u7528 mysqlbinlog \u627e\u51fa\u5220\u9664\u8868\u7684\u4e8c\u8fdb\u5236\u65e5\u5fd7\u5c06\u4e8c\u8fdb\u5236\u65e5\u5fd7\u5bfc\u5165\u6216\u91cd\u65b0\u5e94\u7528\u6570\u636e\u6587\u4ef6\u6062\u590d\uff1a\u627e\u5230\u88ab\u5220\u8868\u7684 .frm\u3001.ibd \u548c .myi \u6587\u4ef6\u521b\u5efa\u76f8\u540c\u7ed3\u6784\u7684\u65b0\u8868\u505c\u6b62 mysql \u5e76\u66ff\u6362\u65b0\u8868\u7684\u6587\u4ef6\u4e3a\u65e7\u6587\u4ef6\u542f\u52a8 mysql \u5e76\u68c0\u67e5\u65b0\u8868\u6570\u636e MySQL \u8868\u8bef\u5220\u6062\u590d\u65b9\u6cd5 \u5f53 MySQL \u8868\u88ab\u610f\u5916\u5220\u9664\u65f6\uff0c\u6709\u4e24\u79cd\u65b9\u6cd5\u53ef\u4ee5\u5c1d\u8bd5\u6062\u590d\uff1a \u65b9\u6cd5\u4e00\uff1a\u4e8c\u8fdb\u5236\u65e5\u5fd7 (binlog) \u786e\u8ba4\u670d\u52a1\u5668\u542f\u7528\u4e8c\u8fdb\u5236\u65e5\u5fd7\u8bb0\u5f55\u3002 \u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u627e\u51fa\u5220\u9664\u8868\u7684\u4e8c\u8fdb\u5236\u65e5\u5fd7\uff1a mysqlbinlog &#8211;start-position=NNN &#8211;stop-position=MMM &#8211;database=&lt;database_name&gt; &lt;log_file&gt; \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d\uff0cNNN \u548c MMM \u662f\u5220\u9664\u64cd\u4f5c\u53d1\u751f\u524d\u540e\u7684\u4e8c\u8fdb\u5236\u65e5\u5fd7\u4f4d\u7f6e\u3002 \u70b9\u51fb\u4e0b\u8f7d\u201c\u201d\uff1b \u5c06\u627e\u5230\u7684\u4e8c\u8fdb\u5236\u65e5\u5fd7\u5bfc\u5165\u53e6\u4e00\u4e2a\u6570\u636e\u5e93\u5b9e\u4f8b\u6216\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u91cd\u65b0\u5e94\u7528\uff1a mysql &#8211;binlog=&lt;log_file&gt; \u767b\u5f55\u540e\u590d\u5236 \u65b9\u6cd5\u4e8c\uff1a\u6570\u636e\u6587\u4ef6\u6062\u590d \u627e\u5230\u88ab\u5220\u9664\u8868\u7684 .frm\u3001.ibd \u548c .MYI \u6587\u4ef6\uff0c\u5b83\u4eec\u901a\u5e38\u4f4d\u4e8e MySQL \u6570\u636e\u76ee\u5f55\u7684 \/data\/ \u5b50\u76ee\u5f55\u4e2d\u3002 \u5728\u53e6\u4e00\u4e2a MySQL \u5b9e\u4f8b\u4e2d\uff0c\u521b\u5efa\u4e0e\u88ab\u5220\u9664\u8868\u7ed3\u6784\u76f8\u540c\u7684\u65b0\u8868\u3002 \u505c\u6b62 MySQL \u5b9e\u4f8b\u5e76\u66ff\u6362\u65b0\u8868\u7684 .frm\u3001.ibd \u548c .MYI [&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-5518","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5518","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=5518"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5518\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5518"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5518"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5518"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}