{"id":6477,"date":"2024-11-14T14:41:02","date_gmt":"2024-11-14T06:41:02","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6477\/"},"modified":"2024-11-14T14:41:02","modified_gmt":"2024-11-14T06:41:02","slug":"mysql%e6%95%b0%e6%8d%ae%e5%ba%93%e6%bb%a1%e4%ba%86%e6%80%8e%e4%b9%88%e5%8a%9e","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6477\/","title":{"rendered":"mysql\u6570\u636e\u5e93\u6ee1\u4e86\u600e\u4e48\u529e"},"content":{"rendered":"<blockquote><p>\n  \u89e3\u51b3 mysql \u6570\u636e\u5e93\u5df2\u6ee1\u65f6\u7684\u65b9\u6848\u6709\uff1a\u6269\u5927\u6570\u636e\u5e93\u5bb9\u91cf\uff1a\u4fee\u6539\u914d\u7f6e\u6587\u4ef6\u589e\u52a0\u6587\u4ef6\u5927\u5c0f\u3002\u6e05\u7406\u4e0d\u9700\u8981\u7684\u6570\u636e\uff1a\u5220\u9664\u65e5\u5fd7\u6587\u4ef6\u3001\u91cd\u590d\u8bb0\u5f55\u548c\u4e0d\u7528\u7684\u8868\u3002\u4f18\u5316\u8868\u7ed3\u6784\uff1a\u9009\u62e9\u5408\u9002\u7684\u6570\u636e\u7c7b\u578b\u3001\u521b\u5efa\u7d22\u5f15\u3001\u5206\u533a\u8868\u3002\u538b\u7f29\u6570\u636e\uff1a\u4f7f\u7528 row_format=compressed \u9009\u9879\u6216\u538b\u7f29\u73b0\u6709\u8868\u3002\u5347\u7ea7 mysql \u7248\u672c\uff1a\u5229\u7528\u8f83\u65b0\u7248\u672c\u7684\u5b58\u50a8\u4f18\u5316\u529f\u80fd\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202408\/05\/2024080508192979719.jpg\" class=\"aligncenter\" title=\"mysql\u6570\u636e\u5e93\u6ee1\u4e86\u600e\u4e48\u529e\u63d2\u56fe\" alt=\"mysql\u6570\u636e\u5e93\u6ee1\u4e86\u600e\u4e48\u529e\u63d2\u56fe\" \/><\/p>\n<h2>MySQL \u6570\u636e\u5e93\u5df2\u6ee1\u7684\u89e3\u51b3\u65b9\u6848<\/h2>\n<p>\u5f53 MySQL \u6570\u636e\u5e93\u8fbe\u5230\u5b58\u50a8\u5bb9\u91cf\u4e0a\u9650\u65f6\uff0c\u4f1a\u51fa\u73b0\u201c\u7a7a\u95f4\u4e0d\u8db3\u201d\u9519\u8bef\u3002\u89e3\u51b3\u8fd9\u4e00\u95ee\u9898\u7684\u51e0\u79cd\u65b9\u6cd5\u5982\u4e0b\uff1a<\/p>\n<h3>1. \u6269\u5927\u6570\u636e\u5e93\u5bb9\u91cf<\/h3>\n<p>\u6700\u76f4\u63a5\u7684\u89e3\u51b3\u65b9\u6848\u662f\u589e\u52a0\u6570\u636e\u5e93\u7684\u5b58\u50a8\u5bb9\u91cf\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u8fdb\u884c\uff1a<\/p>\n<ul>\n<li>\u4fee\u6539 MySQL \u914d\u7f6e\u6587\u4ef6 my.cnf\uff0c\u589e\u52a0 innodb_data_file_path \u53c2\u6570\u4e2d\u7684\u6587\u4ef6\u5927\u5c0f\u3002<\/li>\n<li>\u91cd\u65b0\u542f\u52a8 MySQL \u670d\u52a1\uff0c\u66f4\u6539\u751f\u6548\u3002<\/li>\n<\/ul>\n<h3>2. \u6e05\u7406\u4e0d\u9700\u8981\u7684\u6570\u636e<\/h3>\n<p>\u968f\u7740\u65f6\u95f4\u7684\u63a8\u79fb\uff0c\u6570\u636e\u5e93\u4e2d\u53ef\u80fd\u4f1a\u79ef\u7d2f\u5f88\u591a\u4e0d\u9700\u8981\u7684\u6570\u636e\uff0c\u4f8b\u5982\uff1a<\/p>\n<ul>\n<li>\u8fc7\u671f\u7684\u65e5\u5fd7\u6587\u4ef6<\/li>\n<li>\u91cd\u590d\u7684\u8bb0\u5f55<\/li>\n<li>\u8f83\u5c11\u4f7f\u7528\u7684\u8868<\/li>\n<\/ul>\n<p>\u901a\u8fc7\u6e05\u7406\u8fd9\u4e9b\u6570\u636e\uff0c\u53ef\u4ee5\u91ca\u653e\u51fa\u5927\u91cf\u7684\u5b58\u50a8\u7a7a\u95f4\u3002\u53ef\u4ee5\u6267\u884c\u4ee5\u4e0b\u64cd\u4f5c\uff1a<\/p>\n<ul>\n<li>\u5220\u9664\u65e7\u7684\u65e5\u5fd7\u6587\u4ef6\uff1aDELETE FROM .general_log WHERE event_time <\/li>\n<li>\u5220\u9664\u91cd\u590d\u7684\u8bb0\u5f55\uff1a\u4f7f\u7528 DISTINCT \u6216 GROUP BY \u8bed\u53e5\u67e5\u8be2\u552f\u4e00\u8bb0\u5f55\u5e76\u5220\u9664\u91cd\u590d\u9879\u3002<\/li>\n<li>\u5220\u9664\u4e0d\u7528\u7684\u8868\uff1aDROP TABLE table_name;<\/li>\n<\/ul>\n<h3>3. \u4f18\u5316\u8868\u7ed3\u6784<\/h3>\n<p>\u6570\u636e\u5e93\u8868\u7684\u7ed3\u6784\u4e5f\u4f1a\u5f71\u54cd\u5b58\u50a8\u7a7a\u95f4\u7684\u4f7f\u7528\u3002\u53ef\u4ee5\u91c7\u53d6\u4ee5\u4e0b\u4f18\u5316\u63aa\u65bd\uff1a<\/p>\n<ul>\n<li>\u4f7f\u7528\u9002\u5408\u7684\u6570\u636e\u7c7b\u578b\uff1a\u9009\u62e9\u5408\u9002\u7684\u5b57\u6bb5\u7c7b\u578b\uff0c\u907f\u514d\u4f7f\u7528 TEXT \u6216 BLOB \u7b49\u8f83\u5927\u7684\u7c7b\u578b\u3002<\/li>\n<li>\u521b\u5efa\u7d22\u5f15\uff1a\u4e3a\u7ecf\u5e38\u67e5\u8be2\u7684\u5217\u521b\u5efa\u7d22\u5f15\u53ef\u4ee5\u51cf\u5c11\u67e5\u8be2\u65f6\u95f4\u548c\u6240\u9700\u7684\u5b58\u50a8\u7a7a\u95f4\u3002<\/li>\n<li>\u5206\u533a\u8868\uff1a\u5c06\u5927\u578b\u8868\u5206\u6210\u8f83\u5c0f\u7684\u5206\u533a\uff0c\u53ef\u4ee5\u66f4\u6709\u6548\u5730\u7ba1\u7406\u5b58\u50a8\u7a7a\u95f4\u3002<\/li>\n<\/ul>\n<h3>4. \u538b\u7f29\u6570\u636e<\/h3>\n<p>MySQL \u63d0\u4f9b\u4e86\u538b\u7f29\u6570\u636e\u7684\u529f\u80fd\uff0c\u53ef\u4ee5\u663e\u8457\u8282\u7701\u5b58\u50a8\u7a7a\u95f4\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5\uff1a<\/p>\n<ul>\n<li>\u4f7f\u7528 ROW_FORMAT=COMPRESSED \u521b\u5efa\u65b0\u8868\uff1a\u6b64\u9009\u9879\u4f1a\u81ea\u52a8\u538b\u7f29\u8868\u4e2d\u7684\u6570\u636e\u3002<\/li>\n<li>\u538b\u7f29\u73b0\u6709\u8868\uff1aALTER TABLE table_name ROW_FORMAT=COMPRESSED;<\/li>\n<\/ul>\n<h3>5. \u5347\u7ea7 MySQL \u7248\u672c<\/h3>\n<p>\u8f83\u65b0\u7684 MySQL \u7248\u672c\u901a\u5e38\u5305\u542b\u66f4\u597d\u7684\u5b58\u50a8\u7ba1\u7406\u529f\u80fd\u3002\u5347\u7ea7\u5230\u6700\u65b0\u7248\u672c\u53ef\u4ee5\u5229\u7528\u8fd9\u4e9b\u6539\u8fdb\uff0c\u63d0\u9ad8\u6570\u636e\u5e93\u7684\u5b58\u50a8\u6548\u7387\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u6570\u636e\u5e93\u6ee1\u4e86\u600e\u4e48\u529e\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>\u89e3\u51b3 mysql \u6570\u636e\u5e93\u5df2\u6ee1\u65f6\u7684\u65b9\u6848\u6709\uff1a\u6269\u5927\u6570\u636e\u5e93\u5bb9\u91cf\uff1a\u4fee\u6539\u914d\u7f6e\u6587\u4ef6\u589e\u52a0\u6587\u4ef6\u5927\u5c0f\u3002\u6e05\u7406\u4e0d\u9700\u8981\u7684\u6570\u636e\uff1a\u5220\u9664\u65e5\u5fd7\u6587\u4ef6\u3001\u91cd\u590d\u8bb0\u5f55\u548c\u4e0d\u7528\u7684\u8868\u3002\u4f18\u5316\u8868\u7ed3\u6784\uff1a\u9009\u62e9\u5408\u9002\u7684\u6570\u636e\u7c7b\u578b\u3001\u521b\u5efa\u7d22\u5f15\u3001\u5206\u533a\u8868\u3002\u538b\u7f29\u6570\u636e\uff1a\u4f7f\u7528 row_format=compressed \u9009\u9879\u6216\u538b\u7f29\u73b0\u6709\u8868\u3002\u5347\u7ea7 mysql \u7248\u672c\uff1a\u5229\u7528\u8f83\u65b0\u7248\u672c\u7684\u5b58\u50a8\u4f18\u5316\u529f\u80fd\u3002 MySQL \u6570\u636e\u5e93\u5df2\u6ee1\u7684\u89e3\u51b3\u65b9\u6848 \u5f53 MySQL \u6570\u636e\u5e93\u8fbe\u5230\u5b58\u50a8\u5bb9\u91cf\u4e0a\u9650\u65f6\uff0c\u4f1a\u51fa\u73b0\u201c\u7a7a\u95f4\u4e0d\u8db3\u201d\u9519\u8bef\u3002\u89e3\u51b3\u8fd9\u4e00\u95ee\u9898\u7684\u51e0\u79cd\u65b9\u6cd5\u5982\u4e0b\uff1a 1. \u6269\u5927\u6570\u636e\u5e93\u5bb9\u91cf \u6700\u76f4\u63a5\u7684\u89e3\u51b3\u65b9\u6848\u662f\u589e\u52a0\u6570\u636e\u5e93\u7684\u5b58\u50a8\u5bb9\u91cf\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u8fdb\u884c\uff1a \u4fee\u6539 MySQL \u914d\u7f6e\u6587\u4ef6 my.cnf\uff0c\u589e\u52a0 innodb_data_file_path \u53c2\u6570\u4e2d\u7684\u6587\u4ef6\u5927\u5c0f\u3002 \u91cd\u65b0\u542f\u52a8 MySQL \u670d\u52a1\uff0c\u66f4\u6539\u751f\u6548\u3002 2. \u6e05\u7406\u4e0d\u9700\u8981\u7684\u6570\u636e \u968f\u7740\u65f6\u95f4\u7684\u63a8\u79fb\uff0c\u6570\u636e\u5e93\u4e2d\u53ef\u80fd\u4f1a\u79ef\u7d2f\u5f88\u591a\u4e0d\u9700\u8981\u7684\u6570\u636e\uff0c\u4f8b\u5982\uff1a \u8fc7\u671f\u7684\u65e5\u5fd7\u6587\u4ef6 \u91cd\u590d\u7684\u8bb0\u5f55 \u8f83\u5c11\u4f7f\u7528\u7684\u8868 \u901a\u8fc7\u6e05\u7406\u8fd9\u4e9b\u6570\u636e\uff0c\u53ef\u4ee5\u91ca\u653e\u51fa\u5927\u91cf\u7684\u5b58\u50a8\u7a7a\u95f4\u3002\u53ef\u4ee5\u6267\u884c\u4ee5\u4e0b\u64cd\u4f5c\uff1a \u5220\u9664\u65e7\u7684\u65e5\u5fd7\u6587\u4ef6\uff1aDELETE FROM .general_log WHERE event_time \u5220\u9664\u91cd\u590d\u7684\u8bb0\u5f55\uff1a\u4f7f\u7528 DISTINCT \u6216 GROUP BY \u8bed\u53e5\u67e5\u8be2\u552f\u4e00\u8bb0\u5f55\u5e76\u5220\u9664\u91cd\u590d\u9879\u3002 \u5220\u9664\u4e0d\u7528\u7684\u8868\uff1aDROP TABLE table_name; 3. \u4f18\u5316\u8868\u7ed3\u6784 \u6570\u636e\u5e93\u8868\u7684\u7ed3\u6784\u4e5f\u4f1a\u5f71\u54cd\u5b58\u50a8\u7a7a\u95f4\u7684\u4f7f\u7528\u3002\u53ef\u4ee5\u91c7\u53d6\u4ee5\u4e0b\u4f18\u5316\u63aa\u65bd\uff1a \u4f7f\u7528\u9002\u5408\u7684\u6570\u636e\u7c7b\u578b\uff1a\u9009\u62e9\u5408\u9002\u7684\u5b57\u6bb5\u7c7b\u578b\uff0c\u907f\u514d\u4f7f\u7528 TEXT \u6216 BLOB \u7b49\u8f83\u5927\u7684\u7c7b\u578b\u3002 \u521b\u5efa\u7d22\u5f15\uff1a\u4e3a\u7ecf\u5e38\u67e5\u8be2\u7684\u5217\u521b\u5efa\u7d22\u5f15\u53ef\u4ee5\u51cf\u5c11\u67e5\u8be2\u65f6\u95f4\u548c\u6240\u9700\u7684\u5b58\u50a8\u7a7a\u95f4\u3002 \u5206\u533a\u8868\uff1a\u5c06\u5927\u578b\u8868\u5206\u6210\u8f83\u5c0f\u7684\u5206\u533a\uff0c\u53ef\u4ee5\u66f4\u6709\u6548\u5730\u7ba1\u7406\u5b58\u50a8\u7a7a\u95f4\u3002 [&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-6477","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6477","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=6477"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6477\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6477"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6477"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6477"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}