{"id":5785,"date":"2024-11-14T09:52:17","date_gmt":"2024-11-14T01:52:17","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5785\/"},"modified":"2024-11-14T09:52:17","modified_gmt":"2024-11-14T01:52:17","slug":"mysql%e7%8e%af%e5%a2%83%e5%8f%98%e9%87%8f%e6%80%8e%e4%b9%88%e7%94%a8","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5785\/","title":{"rendered":"mysql\u73af\u5883\u53d8\u91cf\u600e\u4e48\u7528"},"content":{"rendered":"<blockquote><p>\n  mysql \u73af\u5883\u53d8\u91cf\u662f\u5173\u952e\u503c\u5bf9\uff0c\u7528\u4e8e\u81ea\u5b9a\u4e49 mysql \u670d\u52a1\u5668\u914d\u7f6e\u3002\u4f7f\u7528 set \u8bed\u53e5\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\uff0c\u53ef\u4ee5\u4f7f\u7528 global \u6216 session \u5173\u952e\u5b57\u8bbe\u7f6e\u5168\u5c40\u6216\u4f1a\u8bdd\u53d8\u91cf\u3002\u5e38\u89c1\u73af\u5883\u53d8\u91cf\u5305\u62ec innodb_buffer_pool_size\u3001innodb_flush_log_at_trx_commit\u3001max_connections\u3001wait_timeout \u548c character_set_server\u3002\u73af\u5883\u53d8\u91cf\u66f4\u6539\u4e0d\u4f1a\u6301\u4e45\u5316\u5230\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u67d0\u4e9b\u53d8\u91cf\u4ec5\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u53ef\u8bbe\u7f6e\uff0c\u4e0d\u5f53\u8bbe\u7f6e\u53ef\u80fd\u5bfc\u81f4\u95ee\u9898\u3002\u6b63\u786e\u4f7f\u7528\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202406\/02\/2024060201245480665.jpg\" class=\"aligncenter\" title=\"mysql\u73af\u5883\u53d8\u91cf\u600e\u4e48\u7528\u63d2\u56fe\" alt=\"mysql\u73af\u5883\u53d8\u91cf\u600e\u4e48\u7528\u63d2\u56fe\" \/><\/p>\n<p><strong>MySQL \u73af\u5883\u53d8\u91cf\u7684\u4f7f\u7528<\/strong><\/p>\n<p><strong>\u4ec0\u4e48\u662f MySQL \u73af\u5883\u53d8\u91cf\uff1f<\/strong><\/p>\n<p>MySQL \u73af\u5883\u53d8\u91cf\u662f\u5b58\u50a8\u548c\u7ba1\u7406 MySQL \u670d\u52a1\u5668\u914d\u7f6e\u8bbe\u7f6e\u7684\u5173\u3002\u5b83\u4eec\u4f7f\u7ba1\u7406\u5458\u80fd\u591f\u81ea\u5b9a\u4e49 MySQL \u7684\u884c\u4e3a\uff0c\u800c\u65e0\u9700\u4fee\u6539\u914d\u7f6e\u6587\u4ef6\u3002<\/p>\n<p><strong>\u5982\u4f55\u4f7f\u7528 MySQL \u73af\u5883\u53d8\u91cf\uff1f<\/strong><\/p>\n<p>\u8981\u4f7f\u7528 MySQL \u73af\u5883\u53d8\u91cf\uff0c\u8bf7\u4f7f\u7528 SET \u8bed\u53e5\u4ee5\u4ee5\u4e0b\u8bed\u6cd5\u683c\u5f0f\uff1a<\/p>\n<pre>SET global\/session variable_name = value;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li>global \u5173\u952e\u5b57\u8bbe\u7f6e\u4e00\u4e2a\u5168\u5c40\u53d8\u91cf\uff0c\u9002\u7528\u4e8e\u6240\u6709\u8fde\u63a5\u3002<\/li>\n<li>session \u5173\u952e\u5b57\u8bbe\u7f6e\u4e00\u4e2a\u4f1a\u8bdd\u53d8\u91cf\uff0c\u4ec5\u9002\u7528\u4e8e\u5f53\u524d\u8fde\u63a5\u3002<\/li>\n<\/ul>\n<p>\u53d8\u91cf\u540d\u4e0d\u533a\u5206\u5927\u5c0f\u5199\uff0c\u5e76\u4e14\u503c\u53ef\u4ee5\u662f\u5b57\u7b26\u4e32\u3001\u6570\u5b57\u6216\u6807\u8bc6\u7b26\u3002<\/p>\n<p><strong>\u5e38\u89c1 MySQL \u73af\u5883\u53d8\u91cf<\/strong><\/p>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u89c1\u7684 MySQL \u73af\u5883\u53d8\u91cf\uff1a<\/p>\n<ul>\n<li> <strong>innodb_buffer_pool_size<\/strong>\uff1a\u8bbe\u7f6e InnoDB \u7f13\u51b2\u6c60\u7684\u5927\u5c0f\u3002<\/li>\n<li> <strong>innodb_flush_log_at_trx_commit<\/strong>\uff1a\u63a7\u5236 InnoDB \u4f55\u65f6\u5c06\u65e5\u5fd7\u5237\u65b0\u5230\u78c1\u76d8\u3002<\/li>\n<li> <strong>max_connections<\/strong>\uff1a\u8bbe\u7f6e MySQL \u670d\u52a1\u5668\u5141\u8bb8\u7684\u6700\u5927\u8fde\u63a5\u6570\u3002<\/li>\n<li> <strong>wait_timeout<\/strong>\uff1a\u8bbe\u7f6e\u4f1a\u8bdd\u7a7a\u95f2\u540e\u81ea\u52a8\u65ad\u5f00\u8fde\u63a5\u524d\u7684\u79d2\u6570\u3002<\/li>\n<li> <strong>character_set_server<\/strong>\uff1a\u8bbe\u7f6e\u670d\u52a1\u5668\u4f7f\u7528\u7684\u5b57\u7b26\u96c6\u3002<\/li>\n<\/ul>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n<p>\u8981\u5c06\u5168\u5c40\u7f13\u51b2\u6c60\u5927\u5c0f\u8bbe\u7f6e\u4e3a 1GB\uff0c\u4f7f\u7528\u4ee5\u4e0b\u8bed\u53e5\uff1a<\/p>\n<pre>SET global innodb_buffer_pool_size = 1G;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8981\u5c06\u4f1a\u8bdd\u7b49\u5f85\u8d85\u65f6\u8bbe\u7f6e\u4e3a 600 \u79d2\uff0c\u4f7f\u7528\u4ee5\u4e0b\u8bed\u53e5\uff1a<\/p>\n<pre>SET session wait_timeout = 600;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u6ce8\u610f\u4e8b\u9879\uff1a<\/strong><\/p>\n<ul>\n<li>\u66f4\u6539\u73af\u5883\u53d8\u91cf\u4e0d\u4f1a\u6301\u4e45\u5316\u5230\u914d\u7f6e\u6587\u4ef6\u4e2d\u3002<\/li>\n<li>\u67d0\u4e9b\u73af\u5883\u53d8\u91cf\u53ea\u80fd\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bbe\u7f6e\u3002<\/li>\n<li>\u8bbe\u7f6e\u4e0d\u6b63\u786e\u7684\u73af\u5883\u53d8\u91cf\u53ef\u80fd\u5bfc\u81f4 MySQL \u51fa\u73b0\u95ee\u9898\u3002<\/li>\n<\/ul>\n<p>\u4e86\u89e3\u548c\u6b63\u786e\u4f7f\u7528 MySQL \u73af\u5883\u53d8\u91cf\u5bf9\u4e8e\u4f18\u5316\u670d\u52a1\u5668\u6027\u80fd\u548c\u81ea\u5b9a\u4e49\u5176\u884c\u4e3a\u81f3\u5173\u91cd\u8981\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u73af\u5883\u53d8\u91cf\u600e\u4e48\u7528\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 \u73af\u5883\u53d8\u91cf\u662f\u5173\u952e\u503c\u5bf9\uff0c\u7528\u4e8e\u81ea\u5b9a\u4e49 mysql \u670d\u52a1\u5668\u914d\u7f6e\u3002\u4f7f\u7528 set \u8bed\u53e5\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\uff0c\u53ef\u4ee5\u4f7f\u7528 global \u6216 session \u5173\u952e\u5b57\u8bbe\u7f6e\u5168\u5c40\u6216\u4f1a\u8bdd\u53d8\u91cf\u3002\u5e38\u89c1\u73af\u5883\u53d8\u91cf\u5305\u62ec innodb_buffer_pool_size\u3001innodb_flush_log_at_trx_commit\u3001max_connections\u3001wait_timeout \u548c character_set_server\u3002\u73af\u5883\u53d8\u91cf\u66f4\u6539\u4e0d\u4f1a\u6301\u4e45\u5316\u5230\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u67d0\u4e9b\u53d8\u91cf\u4ec5\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u53ef\u8bbe\u7f6e\uff0c\u4e0d\u5f53\u8bbe\u7f6e\u53ef\u80fd\u5bfc\u81f4\u95ee\u9898\u3002\u6b63\u786e\u4f7f\u7528 MySQL \u73af\u5883\u53d8\u91cf\u7684\u4f7f\u7528 \u4ec0\u4e48\u662f MySQL \u73af\u5883\u53d8\u91cf\uff1f MySQL \u73af\u5883\u53d8\u91cf\u662f\u5b58\u50a8\u548c\u7ba1\u7406 MySQL \u670d\u52a1\u5668\u914d\u7f6e\u8bbe\u7f6e\u7684\u5173\u3002\u5b83\u4eec\u4f7f\u7ba1\u7406\u5458\u80fd\u591f\u81ea\u5b9a\u4e49 MySQL \u7684\u884c\u4e3a\uff0c\u800c\u65e0\u9700\u4fee\u6539\u914d\u7f6e\u6587\u4ef6\u3002 \u5982\u4f55\u4f7f\u7528 MySQL \u73af\u5883\u53d8\u91cf\uff1f \u8981\u4f7f\u7528 MySQL \u73af\u5883\u53d8\u91cf\uff0c\u8bf7\u4f7f\u7528 SET \u8bed\u53e5\u4ee5\u4ee5\u4e0b\u8bed\u6cd5\u683c\u5f0f\uff1a SET global\/session variable_name = value; \u767b\u5f55\u540e\u590d\u5236 global \u5173\u952e\u5b57\u8bbe\u7f6e\u4e00\u4e2a\u5168\u5c40\u53d8\u91cf\uff0c\u9002\u7528\u4e8e\u6240\u6709\u8fde\u63a5\u3002 session \u5173\u952e\u5b57\u8bbe\u7f6e\u4e00\u4e2a\u4f1a\u8bdd\u53d8\u91cf\uff0c\u4ec5\u9002\u7528\u4e8e\u5f53\u524d\u8fde\u63a5\u3002 \u53d8\u91cf\u540d\u4e0d\u533a\u5206\u5927\u5c0f\u5199\uff0c\u5e76\u4e14\u503c\u53ef\u4ee5\u662f\u5b57\u7b26\u4e32\u3001\u6570\u5b57\u6216\u6807\u8bc6\u7b26\u3002 \u5e38\u89c1 MySQL \u73af\u5883\u53d8\u91cf \u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u89c1\u7684 MySQL \u73af\u5883\u53d8\u91cf\uff1a innodb_buffer_pool_size\uff1a\u8bbe\u7f6e InnoDB \u7f13\u51b2\u6c60\u7684\u5927\u5c0f\u3002 innodb_flush_log_at_trx_commit\uff1a\u63a7\u5236 InnoDB \u4f55\u65f6\u5c06\u65e5\u5fd7\u5237\u65b0\u5230\u78c1\u76d8\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-5785","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5785","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=5785"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5785\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5785"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5785"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5785"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}