{"id":31713,"date":"2023-05-26T10:56:12","date_gmt":"2023-05-26T02:56:12","guid":{"rendered":"https:\/\/docs.pingcode.com\/?p=31713"},"modified":"2023-07-31T00:10:29","modified_gmt":"2023-07-30T16:10:29","slug":"mysql%e6%80%8e%e4%b9%88%e6%9f%a5%e7%9c%8b%e8%bf%9e%e6%8e%a5%e6%b1%a0%e6%98%af%e5%90%a6%e5%b7%b2%e6%bb%a1","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/31713.html","title":{"rendered":"mysql\u600e\u4e48\u67e5\u770b\u8fde\u63a5\u6c60\u662f\u5426\u5df2\u6ee1"},"content":{"rendered":"<blockquote class=\"wp-block-quote\">\n<p>1.\u67e5\u770b\u8fde\u63a5\u6570\u914d\u7f6e\uff08MySQL\u670d\u52a1\u5668\u5141\u8bb8\u7684\u6700\u5927\u8fde\u63a5\u657016384\uff09show variables like\u2019%max_connections%\u2019\uff1b2.\u67e5\u770b\u5f53\u524d\u8fde\u63a5\u6570\u3002\u65b9\u6cd51\uff1ashow full processlist \uff08\u9700\u8981\u7528\u7ba1\u7406\u5458\u5e10\u53f7\uff09\u3002\u65b9\u6cd52\uff1amysqladmin -u root -proot status\uff08Threads \u503c\u662f\u5f53\u524d\u8fde\u63a5\u6570\uff09\u3002<\/p>\n<\/blockquote>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img fetchpriority=\"high\" alt=\"\" class=\"wp-image-31714\" decoding=\"async\" height=\"421\" sizes=\"(max-width: 680px) 100vw, 680px\" src=\"https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2023\/05\/\u6dfb\u52a0\u6807\u9898-1-15.png?x-oss-process=image\/auto-orient,1\/format,webp\" srcset=\"https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2023\/05\/\u6dfb\u52a0\u6807\u9898-1-15.png?x-oss-process=image\/auto-orient,1\/format,webp 680w, https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2023\/05\/\u6dfb\u52a0\u6807\u9898-1-15-300x186.png 300w\" width=\"680\"\/><\/figure>\n<\/div>\n<h2 class=\"wp-block-heading\"><strong>\u4e00\u3001mysql\u600e\u4e48\u67e5\u770b\u8fde\u63a5\u6c60\u662f\u5426\u5df2\u6ee1<\/strong><\/h2>\n<p>1.\u67e5\u770b\u8fde\u63a5\u6570\u914d\u7f6e\uff08MySQL\u670d\u52a1\u5668\u5141\u8bb8\u7684\u6700\u5927\u8fde\u63a5\u657016384\uff09<br \/>show variables like \u2018%max_connections%\u2019<\/p>\n<p>2.\u67e5\u770b\u5f53\u524d\u8fde\u63a5\u6570<br \/>\u65b9\u6cd51\uff1ashow full processlist \uff08\u9700\u8981\u7528\u7ba1\u7406\u5458\u5e10\u53f7\uff09<\/p>\n<p>\u65b9\u6cd52\uff1amysqladmin -u root -proot status\uff08Threads \u503c\u662f\u5f53\u524d\u8fde\u63a5\u6570\uff09<br \/>\u5982\u679c\u5f53\u524d\u8fde\u63a5\u6570\u548c\u8fde\u63a5\u6570\u914d\u7f6e\u63a5\u8fd1\uff0c\u8bf4\u660e\u8fde\u63a5\u6570\u5dee\u4e0d\u591a\u6ee1\u4e86\u3002<\/p>\n<p>\u4f7f\u7528 MySQL \u6570\u636e\u5e93\u7684\u7ad9\u70b9\uff0c\u5f53\u8bbf\u95ee\u8fde\u63a5\u6570\u8fc7\u591a\u65f6\uff0c\u5c31\u4f1a\u51fa\u73b0 \u201cToo many connections\u201d \u7684\u9519\u8bef\u3002\u51fa\u73b0\u8fd9\u79cd\u9519\u8bef\u6709\u4e24\u79cd\u60c5\u51b5\uff0c\u4e00\u79cd\u662f\u7f51\u7ad9\u8bbf\u95ee\u91cf\u5b9e\u5728\u592a\u5927\uff0c\u670d\u52a1\u5668\u5df2\u7ecf\u8d1f\u62c5\u4e0d\u8d77\uff0c\u6b64\u65f6\u5c31\u5e94\u8be5\u8003\u8651\u8d1f\u8f7d\u5747\u8861\u6216\u8005\u5176\u5b83\u51cf\u5c11\u670d\u52a1\u5668\u538b\u529b\u7684\u529e\u6cd5\u3002\u53e6\u4e00\u79cd\u60c5\u51b5\u5c31\u662f MySQL \u7684\u8fde\u63a5\u6c60\u5927\u8fde\u63a5\u6570\u8bbe\u7f6e\u5f97\u592a\u5c0f\uff0c\u5f53\u8bbf\u95ee\u91cf\u7a0d\u5927\u5c31\u51fa\u73b0\u8fde\u63a5\u8fc7\u591a\u7684\u9519\u8bef\u3002win7\u4e0b\u914d\u7f6ePHP+Apache+Mysql\u8fd0\u884c\u73af\u5883<\/p>\n<p>MySQL \u9ed8\u8ba4\u7684\u8fde\u63a5\u6c60\u5927\u8fde\u63a5\u6570\u4e3a 100\uff0c\u53ef\u4ee5\u5728 mysql \u5ba2\u6237\u7aef\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b<br \/>mysql&gt; show variables like \u2018max_connections\u2019;<\/p>\n<p>\u6b64\u547d\u4ee4\u5c06\u5f97\u5230\u7c7b\u4f3c\u4ee5\u4e0b\u7684\u8f93\u51fa\u7ed3\u679c\uff1a<\/p>\n<p>+\u2014\u2014\u2014\u2014\u2014\u2013+\u2014\u2014-+<br \/>| Variable_name | Value |<br \/>+\u2014\u2014\u2014\u2014\u2014\u2013+\u2014\u2014-+<br \/>| max_connections | 2000 |<br \/>+\u2014\u2014\u2014\u2014\u2014\u2013+\u2014\u2014-+<br \/>1 row in set (0.00 sec)<\/p>\n<p>\u3000\u3000\u8981\u5bf9 mysql \u7684\u8fde\u63a5\u6c60\u5927\u8fde\u63a5\u6570\u8fdb\u884c\u4fee\u6539\uff0c\u53ea\u9700\u8981\u5728 my.cnf \u914d\u7f6e\u6587\u4ef6\u91cc\u9762\u4fee\u6539 max_connections \u7684\u503c\uff0c\u7136\u540e\u91cd\u542f mysql \u5c31\u884c\u3002\u5982\u679c my.ini \u6587\u4ef6\u4e2d\u6ca1\u6709\u627e\u5230 max_connections \u6761\u76ee\uff0c\u53ef\u81ea\u884c\u6dfb\u52a0\u4ee5\u4e0b\u6761\u76ee<\/p>\n<p>max_connections = 200<\/p>\n<h3 class=\"wp-block-heading\"><strong>\u4fee\u6539MySQL\u8fde\u63a5\u6c60\u5927\u8fde\u63a5\u6570<\/strong><\/h3>\n<p>\u65b9\u6cd5\u4e00\uff1a<\/p>\n<p>\u8fdb\u5165MySQL\u5b89\u88c5\u76ee\u5f55 \u6253\u5f00MySQL\u914d\u7f6e\u6587\u4ef6 my.ini \u6216 my.cnf\u67e5\u627e max_connections=100 \u4fee\u6539\u4e3a max_connections=1000 \u670d\u52a1\u91cc\u91cd\u8d77MySQL\u5373\u53ef<\/p>\n<p>\u65b9\u6cd5\u4e8c\uff1a<\/p>\n<p>MySQL\u8fde\u63a5\u6c60\u5927\u8fde\u63a5\u6570\u9ed8\u8ba4\u662f100\u5ba2\u6237\u7aef\u767b\u5f55\uff1a<\/p>\n<p>MySQL -uusername -ppassword<\/p>\n<p>\u8bbe\u7f6e\u65b0\u7684MySQL\u8fde\u63a5\u6c60\u5927\u8fde\u63a5\u6570\u4e3a200\uff1a<\/p>\n<p>MySQL&gt; set GLOBAL max_connections=200<\/p>\n<p>\u663e\u793a\u5f53\u524d\u8fd0\u884c\u7684Query\uff1a<\/p>\n<p>MySQL&gt; show processlist<\/p>\n<p>\u663e\u793a\u5f53\u524d\u72b6\u6001\uff1a<\/p>\n<p>MySQL&gt; show status<\/p>\n<p>\u9000\u51fa\u5ba2\u6237\u7aef\uff1aMySQL&gt; exit<\/p>\n<p>\u67e5\u770b\u5f53\u524dMySQL\u8fde\u63a5\u6c60\u5927\u8fde\u63a5\u6570\uff1aMySQLadmin -uusername -ppassword variables<\/p>\n<p>\u65b9\u6cd5\u4e09\uff1a<\/p>\n<p>\u4ee5centos 4.4 \u4e0b\u9762\u7684MySQL 5.0.33 \u624b\u5de5\u7f16\u8bd1\u7248\u672c\u4e3a\u4f8b\u8bf4\u660e\uff1a<\/p>\n<p>vi \/usr\/local\/MySQL\/bin\/MySQLd_<a href=\"https:\/\/docs.pingcode.com\/agile\/agile-at-scale\/what-is-safe\" target=\"_blank\">SAFe<\/a><\/p>\n<p>\u627e\u5230<a href=\"https:\/\/docs.pingcode.com\/agile\/agile-at-scale\/what-is-safe\" target=\"_blank\">SAFe<\/a>_MySQLd\u7f16\u8f91\u5b83\uff0c\u627e\u5230MySQLd\u542f\u52a8\u7684\u90a3\u4e24\u884c\uff0c\u5728\u540e\u9762\u52a0\u4e0a\u53c2\u6570 \uff1a<\/p>\n<p>-O max_connections=1500<\/p>\n<p>\u5177\u4f53\u4e00\u70b9\u5c31\u662f\u4e0b\u9762\u7684\u4f4d\u7f6e\uff1a<\/p>\n<p>then $NOHUP_NICENESS $ledir\/$MySQLD\u00a0 \u00a0 \u00a0<\/p>\n<p><strong>\u5ef6\u4f38\u9605\u8bfb\uff1a<\/strong><\/p>\n<h2 class=\"wp-block-heading\"><strong>\u4e8c\u3001undo log\u7684\u5de5\u4f5c\u539f\u7406<\/strong><\/h2>\n<p>\u5728\u66f4\u65b0\u6570\u636e\u4e4b\u524d\uff0cMySQL\u4f1a\u63d0\u524d\u751f\u6210undo log\u65e5\u5fd7\uff0c\u5f53\u4e8b\u52a1\u63d0\u4ea4\u7684\u65f6\u5019\uff0c\u5e76\u4e0d\u4f1a\u7acb\u5373\u5220\u9664undo log\uff0c\u56e0\u4e3a\u540e\u9762\u53ef\u80fd\u9700\u8981\u8fdb\u884c\u56de\u6eda\u64cd\u4f5c\uff0c\u8981\u6267\u884c\u56de\u6eda\uff08rollback\uff09\u64cd\u4f5c\u65f6\uff0c\u4ece\u7f13\u5b58\u4e2d\u8bfb\u53d6\u6570\u636e\u3002undo log\u65e5\u5fd7\u7684\u5220\u9664\u662f\u901a\u8fc7\u901a\u8fc7\u540e\u53f0purge\u7ebf\u7a0b\u8fdb\u884c\u56de\u6536\u5904\u7406\u7684\u3002<\/p>\n<p>1\u3001\u4e8b\u52a1A\u6267\u884cupdate\u64cd\u4f5c\uff0c\u6b64\u65f6\u4e8b\u52a1\u8fd8\u6ca1\u63d0\u4ea4\uff0c\u4f1a\u5c06\u6570\u636e\u8fdb\u884c\u5907\u4efd\u5230\u5bf9\u5e94\u7684undo buffer\uff0c\u7136\u540e\u7531undo buffer\u6301\u4e45\u5316\u5230\u78c1\u76d8\u4e2d\u7684undo log\u6587\u4ef6\u4e2d\uff0c\u6b64\u65f6undo log\u4fdd\u5b58\u4e86\u672a\u63d0\u4ea4\u4e4b\u524d\u7684\u64cd\u4f5c\u65e5\u5fd7\uff0c\u63a5\u7740\u5c06\u64cd\u4f5c\u7684\u6570\u636e\uff0c\u4e5f\u5c31\u662fTeacher\u8868\u7684\u6570\u636e\u6301\u4e45\u4fdd\u5b58\u5230InnoDB\u7684\u6570\u636e\u6587\u4ef6IBD\u3002<\/p>\n<p>2\u3001\u6b64\u65f6\u4e8b\u52a1B\u8fdb\u884c\u67e5\u8be2\u64cd\u4f5c\uff0c\u76f4\u63a5\u4eceundo buffer\u7f13\u5b58\u4e2d\u8fdb\u884c\u8bfb\u53d6\uff0c\u8fd9\u65f6\u4e8b\u52a1A\u8fd8\u6ca1\u63d0\u4ea4\u4e8b\u52a1\uff0c\u5982\u679c\u8981\u56de\u6eda\uff08rollback\uff09\u4e8b\u52a1\uff0c\u662f\u4e0d\u8bfb\u78c1\u76d8\u7684\uff0c\u5148\u76f4\u63a5\u4eceundo buffer\u7f13\u5b58\u8bfb\u53d6\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"1.\u67e5\u770b\u8fde\u63a5\u6570\u914d\u7f6e\uff08MySQL\u670d\u52a1\u5668\u5141\u8bb8\u7684\u6700\u5927\u8fde\u63a5\u657016384\uff09show variables like\u2019%ma [&hellip;]","protected":false},"author":1,"featured_media":31714,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/31713"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=31713"}],"version-history":[{"count":0,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/31713\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/31714"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=31713"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=31713"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=31713"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}