{"id":6532,"date":"2024-11-14T08:26:55","date_gmt":"2024-11-14T00:26:55","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6532\/"},"modified":"2024-11-14T08:26:55","modified_gmt":"2024-11-14T00:26:55","slug":"%e6%80%8e%e4%b9%88%e5%88%a0%e9%99%a4mysql%e6%95%b0%e6%8d%ae%e5%ba%93%e6%97%a5%e5%bf%97","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6532\/","title":{"rendered":"\u600e\u4e48\u5220\u9664mysql\u6570\u636e\u5e93\u65e5\u5fd7"},"content":{"rendered":"<blockquote><p>\n  \u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u5220\u9664 mysql \u6570\u636e\u5e93\u65e5\u5fd7\uff1a\u5220\u9664\u4e8c\u8fdb\u5236\u65e5\u5fd7\uff1a\u4f7f\u7528 purge binary logs \u547d\u4ee4\uff0c\u6307\u5b9a\u8981\u5220\u9664\u7684\u65e5\u5fd7\u540d\u79f0\u3002\u5173\u95ed\u901a\u7528\u65e5\u5fd7\uff1a\u5728 mysql \u914d\u7f6e\u6587\u4ef6\u4e2d\u5c06 general_log \u8bbe\u7f6e\u4e3a off\uff0c\u5e76\u91cd\u542f\u670d\u52a1\u3002\u624b\u52a8\u5220\u9664\u65e5\u5fd7\u6587\u4ef6\uff1a\u5bfc\u822a\u5230 mysql \u6570\u636e\u76ee\u5f55\uff0c\u4f7f\u7528 rm \u547d\u4ee4\u5220\u9664 .log \u548c .err \u6587\u4ef6\u3002\u81ea\u52a8\u6e05\u7406\u65e5\u5fd7\uff1a\u5728 mysql \u914d\u7f6e\u6587\u4ef6\u4e2d\u8bbe\u7f6e expire_logs_days\uff0c\u6307\u5b9a\u4fdd\u7559\u65e5\u5fd7\u7684\u5929\u6570\uff0c\u5e76\u91cd\u542f\u670d\u52a1\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202408\/05\/2024080519550719656.jpg\" class=\"aligncenter\" title=\"\u600e\u4e48\u5220\u9664mysql\u6570\u636e\u5e93\u65e5\u5fd7\u63d2\u56fe\" alt=\"\u600e\u4e48\u5220\u9664mysql\u6570\u636e\u5e93\u65e5\u5fd7\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5220\u9664 MySQL \u6570\u636e\u5e93\u65e5\u5fd7<\/strong><\/p>\n<p>MySQL \u6570\u636e\u5e93\u65e5\u5fd7\u8bb0\u5f55\u7740\u6570\u636e\u5e93\u64cd\u4f5c\u548c\u9519\u8bef\u4fe1\u606f\u3002\u4e3a\u4e86\u7ef4\u62a4\u7cfb\u7edf\u7684\u5065\u5eb7\u548c\u6027\u80fd\uff0c\u5b9a\u671f\u6e05\u7406\u65e5\u5fd7\u975e\u5e38\u91cd\u8981\u3002\u4ee5\u4e0b\u662f\u5982\u4f55\u5220\u9664 MySQL \u6570\u636e\u5e93\u65e5\u5fd7\uff1a<\/p>\n<p><strong>\u5220\u9664\u4e8c\u8fdb\u5236\u65e5\u5fd7<\/strong><\/p>\n<ol>\n<li>\u767b\u5f55\u5230 MySQL \u547d\u4ee4\u884c\u754c\u9762\u3002<\/li>\n<li>\n<p>\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>PURGE BINARY LOGS BEFORE '&lt;log_name&gt;'<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5176\u4e2d \u662f\u8981\u5220\u9664\u7684\u4e8c\u8fdb\u5236\u65e5\u5fd7\u7684\u540d\u79f0\u3002 <\/p>\n<\/li>\n<\/ol>\n<p><strong>\u5220\u9664\u901a\u7528\u65e5\u5fd7<\/strong><\/p>\n<ol>\n<li>\u7f16\u8f91 MySQL \u914d\u7f6e\u6587\u4ef6\uff08\u901a\u5e38\u662f \/etc\/my.cnf \u6216 \/etc\/\/my.cnf\uff09\u3002<\/li>\n<li>\u627e\u5230 general_log \u9009\u9879\uff0c\u5e76\u5c06\u5176\u8bbe\u7f6e\u4e3a OFF\u3002<\/li>\n<li>\u91cd\u542f MySQL \u670d\u52a1\u3002<\/li>\n<\/ol>\n<p><strong>\u624b\u52a8\u5220\u9664\u65e5\u5fd7\u6587\u4ef6<\/strong><\/p>\n<ol>\n<li>\u5bfc\u822a\u5230 MySQL \u6570\u636e\u76ee\u5f55\uff08\u901a\u5e38\u662f \/var\/lib\/mysql\uff09\u3002<\/li>\n<li>\u627e\u5230\u4ee5 .log \u6216 .err \u7ed3\u5c3e\u7684\u65e5\u5fd7\u6587\u4ef6\u3002<\/li>\n<li>\u4f7f\u7528 rm \u547d\u4ee4\u5220\u9664\u5b83\u4eec\u3002<\/li>\n<\/ol>\n<p><strong>\u81ea\u52a8\u5316\u65e5\u5fd7\u6e05\u7406<\/strong><br \/>\u4e3a\u4e86\u907f\u514d\u624b\u52a8\u6e05\u7406\u65e5\u5fd7\uff0c\u53ef\u4ee5\u914d\u7f6e MySQL \u81ea\u52a8\u6267\u884c\u6b64\u64cd\u4f5c\u3002<\/p>\n<ol>\n<li>\u7f16\u8f91 MySQL \u914d\u7f6e\u6587\u4ef6\u3002<\/li>\n<li>\n<p>\u6dfb\u52a0\u4ee5\u4e0b\u884c\uff1a<\/p>\n<pre>expire_logs_days = &lt;number_of_days&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5176\u4e2d \u662f\u8981\u4fdd\u7559\u65e5\u5fd7\u7684\u5929\u6570\u3002 <\/p>\n<\/li>\n<li>\u91cd\u542f MySQL \u670d\u52a1\u3002<\/li>\n<\/ol>\n<p>\u901a\u8fc7\u9075\u5faa\u8fd9\u4e9b\u6b65\u9aa4\uff0c\u60a8\u53ef\u4ee5\u6709\u6548\u5730\u5220\u9664 MySQL \u6570\u636e\u5e93\u65e5\u5fd7\uff0c\u4fdd\u6301\u7cfb\u7edf\u5e72\u51c0\u4e14\u9ad8\u6548\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u5220\u9664\u6570\u636e\u5e93\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>\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u5220\u9664 mysql \u6570\u636e\u5e93\u65e5\u5fd7\uff1a\u5220\u9664\u4e8c\u8fdb\u5236\u65e5\u5fd7\uff1a\u4f7f\u7528 purge binary logs \u547d\u4ee4\uff0c\u6307\u5b9a\u8981\u5220\u9664\u7684\u65e5\u5fd7\u540d\u79f0\u3002\u5173\u95ed\u901a\u7528\u65e5\u5fd7\uff1a\u5728 mysql \u914d\u7f6e\u6587\u4ef6\u4e2d\u5c06 general_log \u8bbe\u7f6e\u4e3a off\uff0c\u5e76\u91cd\u542f\u670d\u52a1\u3002\u624b\u52a8\u5220\u9664\u65e5\u5fd7\u6587\u4ef6\uff1a\u5bfc\u822a\u5230 mysql \u6570\u636e\u76ee\u5f55\uff0c\u4f7f\u7528 rm \u547d\u4ee4\u5220\u9664 .log \u548c .err \u6587\u4ef6\u3002\u81ea\u52a8\u6e05\u7406\u65e5\u5fd7\uff1a\u5728 mysql \u914d\u7f6e\u6587\u4ef6\u4e2d\u8bbe\u7f6e expire_logs_days\uff0c\u6307\u5b9a\u4fdd\u7559\u65e5\u5fd7\u7684\u5929\u6570\uff0c\u5e76\u91cd\u542f\u670d\u52a1\u3002 \u5982\u4f55\u5220\u9664 MySQL \u6570\u636e\u5e93\u65e5\u5fd7 MySQL \u6570\u636e\u5e93\u65e5\u5fd7\u8bb0\u5f55\u7740\u6570\u636e\u5e93\u64cd\u4f5c\u548c\u9519\u8bef\u4fe1\u606f\u3002\u4e3a\u4e86\u7ef4\u62a4\u7cfb\u7edf\u7684\u5065\u5eb7\u548c\u6027\u80fd\uff0c\u5b9a\u671f\u6e05\u7406\u65e5\u5fd7\u975e\u5e38\u91cd\u8981\u3002\u4ee5\u4e0b\u662f\u5982\u4f55\u5220\u9664 MySQL \u6570\u636e\u5e93\u65e5\u5fd7\uff1a \u5220\u9664\u4e8c\u8fdb\u5236\u65e5\u5fd7 \u767b\u5f55\u5230 MySQL \u547d\u4ee4\u884c\u754c\u9762\u3002 \u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a PURGE BINARY LOGS BEFORE &#8216;&lt;log_name&gt;&#8217; \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d \u662f\u8981\u5220\u9664\u7684\u4e8c\u8fdb\u5236\u65e5\u5fd7\u7684\u540d\u79f0\u3002 \u5220\u9664\u901a\u7528\u65e5\u5fd7 \u7f16\u8f91 MySQL \u914d\u7f6e\u6587\u4ef6\uff08\u901a\u5e38\u662f \/etc\/my.cnf \u6216 \/etc\/\/my.cnf\uff09\u3002 \u627e\u5230 general_log \u9009\u9879\uff0c\u5e76\u5c06\u5176\u8bbe\u7f6e\u4e3a OFF\u3002 \u91cd\u542f [&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-6532","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6532","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=6532"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6532\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6532"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6532"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6532"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}