{"id":5159,"date":"2024-11-14T12:06:48","date_gmt":"2024-11-14T04:06:48","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5159\/"},"modified":"2024-11-14T12:06:48","modified_gmt":"2024-11-14T04:06:48","slug":"mysql%e8%a1%8c%e9%94%81%e6%80%8e%e4%b9%88%e6%a3%80%e6%b5%8b","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5159\/","title":{"rendered":"mysql\u884c\u9501\u600e\u4e48\u68c0\u6d4b"},"content":{"rendered":"<blockquote><p>\n  mysql \u884c\u9501\u68c0\u6d4b\u7684\u65b9\u6cd5\u662f\u4f7f\u7528 show processlist \u547d\u4ee4\uff0c\u8be6\u7ec6\u6b65\u9aa4\u5305\u62ec\uff1a\u767b\u5f55 mysql \u670d\u52a1\u5668\uff1b\u6267\u884c show processlist \u547d\u4ee4\uff1b\u67e5\u627e &#8220;state&#8221; \u5217\u4e3a &#8220;locked&#8221; \u6216 &#8220;sleep&#8221; \u7684\u8fdb\u7a0b\uff1b\u67e5\u770b\u8fdb\u7a0b\u7684 &#8220;info&#8221; \u5217\uff0c\u83b7\u53d6\u4e0e\u6240\u6301\u9501\u76f8\u5173\u7684\u5176\u4ed6\u4fe1\u606f\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/22\/2024052217453039921.jpg\" class=\"aligncenter\" title=\"mysql\u884c\u9501\u600e\u4e48\u68c0\u6d4b\u63d2\u56fe\" alt=\"mysql\u884c\u9501\u600e\u4e48\u68c0\u6d4b\u63d2\u56fe\" \/><\/p>\n<p><strong>MySQL \u884c\u9501\u68c0\u6d4b<\/strong><\/p>\n<p><strong>\u5982\u4f55\u68c0\u6d4b MySQL \u4e2d\u7684\u884c\u9501\uff1f<\/strong><\/p>\n<p>\u4f7f\u7528 SHOW PROCESSLIST \u547d\u4ee4\u3002<\/p>\n<p><strong>\u8be6\u7ec6\u6b65\u9aa4\uff1a<\/strong><\/p>\n<ol>\n<li>\u767b\u5f55 MySQL \u670d\u52a1\u5668\u3002<\/li>\n<li>\n<p>\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>SHOW PROCESSLIST;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li>\u5728\u7ed3\u679c\u96c6\u4e2d\uff0c\u67e5\u627e\u5217\u4e3a &#8220;State&#8221; \u7684\u5217\u3002\u5b83\u5c06\u663e\u793a\u8fdb\u7a0b\u7684\u5f53\u524d\u72b6\u6001\u3002<\/li>\n<li>\u5982\u679c\u4e00\u4e2a\u8fdb\u7a0b\u7684\u72b6\u6001\u4e3a &#8220;Locked&#8221; \u6216 &#8220;Sleep&#8221;\uff0c\u5219\u8868\u660e\u5b83\u6b63\u5728\u6301\u6709\u884c\u9501\u3002<\/li>\n<li>\u8fdb\u7a0b\u7684 &#8220;Info&#8221; \u5217\u5c06\u663e\u793a\u4e0e\u6240\u6301\u9501\u76f8\u5173\u7684\u5176\u4ed6\u4fe1\u606f\uff0c\u4f8b\u5982\u8868\u7684\u540d\u79f0\u3001\u9501\u5b9a\u7684\u884c ID \u7b49\u3002<\/li>\n<\/ol>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n<pre>mysql&gt; SHOW PROCESSLIST;\n+-----+------+--------------------+-----------------+---------+------+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Id | User | Host | db | Command | Time | State | Info |\n+-----+------+--------------------+-----------------+---------+------+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| 6 | test | localhost | test | Query | 0 | Locked | SELECT * FROM table1 WHERE id = 1 FOR UPDATE |\n+-----+------+--------------------+-----------------+---------+------+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u8fdb\u7a0b ID \u4e3a 6\uff0c\u6b63\u5728\u6301\u6709\u8868 table1 \u4e2d ID \u4e3a 1 \u7684\u884c\u7684\u884c\u9501\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u884c\u9501\u600e\u4e48\u68c0\u6d4b\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 \u884c\u9501\u68c0\u6d4b\u7684\u65b9\u6cd5\u662f\u4f7f\u7528 show processlist \u547d\u4ee4\uff0c\u8be6\u7ec6\u6b65\u9aa4\u5305\u62ec\uff1a\u767b\u5f55 mysql \u670d\u52a1\u5668\uff1b\u6267\u884c show processlist \u547d\u4ee4\uff1b\u67e5\u627e &#8220;state&#8221; \u5217\u4e3a &#8220;locked&#8221; \u6216 &#8220;sleep&#8221; \u7684\u8fdb\u7a0b\uff1b\u67e5\u770b\u8fdb\u7a0b\u7684 &#8220;info&#8221; \u5217\uff0c\u83b7\u53d6\u4e0e\u6240\u6301\u9501\u76f8\u5173\u7684\u5176\u4ed6\u4fe1\u606f\u3002 MySQL \u884c\u9501\u68c0\u6d4b \u5982\u4f55\u68c0\u6d4b MySQL \u4e2d\u7684\u884c\u9501\uff1f \u4f7f\u7528 SHOW PROCESSLIST \u547d\u4ee4\u3002 \u8be6\u7ec6\u6b65\u9aa4\uff1a \u767b\u5f55 MySQL \u670d\u52a1\u5668\u3002 \u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a SHOW PROCESSLIST; \u767b\u5f55\u540e\u590d\u5236 \u5728\u7ed3\u679c\u96c6\u4e2d\uff0c\u67e5\u627e\u5217\u4e3a &#8220;State&#8221; \u7684\u5217\u3002\u5b83\u5c06\u663e\u793a\u8fdb\u7a0b\u7684\u5f53\u524d\u72b6\u6001\u3002 \u5982\u679c\u4e00\u4e2a\u8fdb\u7a0b\u7684\u72b6\u6001\u4e3a &#8220;Locked&#8221; \u6216 &#8220;Sleep&#8221;\uff0c\u5219\u8868\u660e\u5b83\u6b63\u5728\u6301\u6709\u884c\u9501\u3002 \u8fdb\u7a0b\u7684 &#8220;Info&#8221; \u5217\u5c06\u663e\u793a\u4e0e\u6240\u6301\u9501\u76f8\u5173\u7684\u5176\u4ed6\u4fe1\u606f\uff0c\u4f8b\u5982\u8868\u7684\u540d\u79f0\u3001\u9501\u5b9a\u7684\u884c ID \u7b49\u3002 \u793a\u4f8b\uff1a mysql&gt; SHOW PROCESSLIST; +&#8212;&#8211;+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+ | Id | [&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-5159","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5159","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=5159"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5159\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5159"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5159"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5159"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}