{"id":6485,"date":"2024-11-14T08:37:52","date_gmt":"2024-11-14T00:37:52","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6485\/"},"modified":"2024-11-14T08:37:52","modified_gmt":"2024-11-14T00:37:52","slug":"mysql%e6%95%b0%e6%8d%ae%e5%ba%93%e6%80%8e%e4%b9%88%e5%88%a0%e9%99%a4%e6%97%a5%e5%bf%97","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6485\/","title":{"rendered":"mysql\u6570\u636e\u5e93\u600e\u4e48\u5220\u9664\u65e5\u5fd7"},"content":{"rendered":"<blockquote><p>\n  \u901a\u8fc7\u4ee5\u4e0b\u65b9\u6cd5\u53ef\u4ee5\u5220\u9664 mysql \u4e2d\u7684\u65e5\u5fd7\uff1a\u4f7f\u7528 purge binary logs \u8bed\u53e5\u5220\u9664\u6240\u6709\u4e8c\u8fdb\u5236\u65e5\u5fd7\u3002\u4f7f\u7528 reset slave \u8bed\u53e5\u5220\u9664\u4ece\u670d\u52a1\u5668\u4e0a\u7684\u4e8c\u8fdb\u5236\u65e5\u5fd7\u548c\u4e2d\u7ee7\u65e5\u5fd7\u3002\u624b\u52a8\u5220\u9664\u4e8c\u8fdb\u5236\u65e5\u5fd7\u548c\u4e2d\u7ee7\u65e5\u5fd7\u6587\u4ef6\uff0c\u4f46\u9700\u786e\u4fdd\u5907\u4efd\u91cd\u8981\u6570\u636e\u5e76\u4e86\u89e3\u5bf9\u590d\u5236\u7684\u5f71\u54cd\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202408\/05\/2024080517275910588.jpg\" class=\"aligncenter\" title=\"mysql\u6570\u636e\u5e93\u600e\u4e48\u5220\u9664\u65e5\u5fd7\u63d2\u56fe\" alt=\"mysql\u6570\u636e\u5e93\u600e\u4e48\u5220\u9664\u65e5\u5fd7\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5728 MySQL \u4e2d\u5220\u9664\u65e5\u5fd7<\/strong><\/p>\n<p><strong>\u65b9\u6cd5 1\uff1a\u4f7f\u7528 PURGE BINARY LOGS<\/strong><\/p>\n<p>\u6700\u7b80\u5355\u7684\u65b9\u6cd5\u662f\u4f7f\u7528 PURGE BINARY LOGS \u8bed\u53e5\uff0c\u5b83\u5c06\u5220\u9664\u6240\u6709\u4e8c\u8fdb\u5236\u65e5\u5fd7\u3002<\/p>\n<pre>PURGE BINARY LOGS BEFORE 'log_name';<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5176\u4e2d log_name \u662f\u8981\u5220\u9664\u7684\u4e8c\u8fdb\u5236\u65e5\u5fd7\u7684\u540d\u79f0\u3002<\/p>\n<p><strong>\u65b9\u6cd5 2\uff1a\u4f7f\u7528 RESET SLAVE<\/strong><\/p>\n<p>\u5982\u679c\u4f60\u662f\u4ece\u670d\u52a1\u5668\uff0c\u5219\u53ef\u4ee5\u4f7f\u7528 RESET SLAVE \u8bed\u53e5\u5220\u9664\u4e8c\u8fdb\u5236\u65e5\u5fd7\u548c\u4e2d\u7ee7\u65e5\u5fd7\u3002<\/p>\n<pre>RESET SLAVE;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u65b9\u6cd5 3\uff1a\u624b\u52a8\u5220\u9664\u6587\u4ef6<\/strong><\/p>\n<p>\u5982\u679c\u4f60\u77e5\u9053\u4e8c\u8fdb\u5236\u65e5\u5fd7\u548c\u4e2d\u7ee7\u65e5\u5fd7\u6240\u5728\u7684\u4f4d\u7f6e\uff0c\u4e5f\u53ef\u4ee5\u624b\u52a8\u5220\u9664\u5b83\u4eec\u3002<\/p>\n<ol>\n<li>\u505c\u6b62 MySQL \u670d\u52a1\u3002<\/li>\n<li>\u5bfc\u822a\u5230 -data \u76ee\u5f55\uff08\u901a\u5e38\u4f4d\u4e8e \/var\/lib\/mysql\/\uff09\u3002<\/li>\n<li>\u627e\u5230 binary-log.* \u548c relay-log.* \u6587\u4ef6\u3002<\/li>\n<li>\u5220\u9664\u8fd9\u4e9b\u6587\u4ef6\u3002<\/li>\n<\/ol>\n<p><strong>\u6ce8\u610f\uff1a<\/strong><\/p>\n<ul>\n<li>\u5728\u5220\u9664\u65e5\u5fd7\u4e4b\u524d\uff0c\u8bf7\u786e\u4fdd\u5907\u4efd\u6240\u6709\u91cd\u8981\u7684\u6570\u636e\u3002<\/li>\n<li>\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662f PURGE BINARY LOGS\uff0c\u4f60\u9700\u8981\u91cd\u65b0\u542f\u52a8 MySQL \u670d\u52a1\u624d\u80fd\u751f\u6548\u3002<\/li>\n<li>\u5220\u9664\u4e8c\u8fdb\u5236\u65e5\u5fd7\u548c\u4e2d\u7ee7\u65e5\u5fd7\u53ef\u80fd\u4f1a\u5f71\u54cd\u590d\u5236\u3002\u5728\u8fdb\u884c\u6b64\u64cd\u4f5c\u4e4b\u524d\uff0c\u8bf7\u786e\u4fdd\u7406\u89e3\u540e\u679c\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u6570\u636e\u5e93\u600e\u4e48\u5220\u9664\u65e5\u5fd7\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>\u901a\u8fc7\u4ee5\u4e0b\u65b9\u6cd5\u53ef\u4ee5\u5220\u9664 mysql \u4e2d\u7684\u65e5\u5fd7\uff1a\u4f7f\u7528 purge binary logs \u8bed\u53e5\u5220\u9664\u6240\u6709\u4e8c\u8fdb\u5236\u65e5\u5fd7\u3002\u4f7f\u7528 reset slave \u8bed\u53e5\u5220\u9664\u4ece\u670d\u52a1\u5668\u4e0a\u7684\u4e8c\u8fdb\u5236\u65e5\u5fd7\u548c\u4e2d\u7ee7\u65e5\u5fd7\u3002\u624b\u52a8\u5220\u9664\u4e8c\u8fdb\u5236\u65e5\u5fd7\u548c\u4e2d\u7ee7\u65e5\u5fd7\u6587\u4ef6\uff0c\u4f46\u9700\u786e\u4fdd\u5907\u4efd\u91cd\u8981\u6570\u636e\u5e76\u4e86\u89e3\u5bf9\u590d\u5236\u7684\u5f71\u54cd\u3002 \u5982\u4f55\u5728 MySQL \u4e2d\u5220\u9664\u65e5\u5fd7 \u65b9\u6cd5 1\uff1a\u4f7f\u7528 PURGE BINARY LOGS \u6700\u7b80\u5355\u7684\u65b9\u6cd5\u662f\u4f7f\u7528 PURGE BINARY LOGS \u8bed\u53e5\uff0c\u5b83\u5c06\u5220\u9664\u6240\u6709\u4e8c\u8fdb\u5236\u65e5\u5fd7\u3002 PURGE BINARY LOGS BEFORE &#8216;log_name&#8217;; \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d log_name \u662f\u8981\u5220\u9664\u7684\u4e8c\u8fdb\u5236\u65e5\u5fd7\u7684\u540d\u79f0\u3002 \u65b9\u6cd5 2\uff1a\u4f7f\u7528 RESET SLAVE \u5982\u679c\u4f60\u662f\u4ece\u670d\u52a1\u5668\uff0c\u5219\u53ef\u4ee5\u4f7f\u7528 RESET SLAVE \u8bed\u53e5\u5220\u9664\u4e8c\u8fdb\u5236\u65e5\u5fd7\u548c\u4e2d\u7ee7\u65e5\u5fd7\u3002 RESET SLAVE; \u767b\u5f55\u540e\u590d\u5236 \u65b9\u6cd5 3\uff1a\u624b\u52a8\u5220\u9664\u6587\u4ef6 \u5982\u679c\u4f60\u77e5\u9053\u4e8c\u8fdb\u5236\u65e5\u5fd7\u548c\u4e2d\u7ee7\u65e5\u5fd7\u6240\u5728\u7684\u4f4d\u7f6e\uff0c\u4e5f\u53ef\u4ee5\u624b\u52a8\u5220\u9664\u5b83\u4eec\u3002 \u505c\u6b62 MySQL \u670d\u52a1\u3002 \u5bfc\u822a\u5230 -data \u76ee\u5f55\uff08\u901a\u5e38\u4f4d\u4e8e \/var\/lib\/mysql\/\uff09\u3002 \u627e\u5230 binary-log.* [&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-6485","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6485","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=6485"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6485\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6485"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6485"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6485"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}