{"id":5480,"date":"2024-11-14T13:11:52","date_gmt":"2024-11-14T05:11:52","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5480\/"},"modified":"2024-11-14T13:11:52","modified_gmt":"2024-11-14T05:11:52","slug":"mysql%e6%ad%bb%e9%94%81%e6%80%8e%e4%b9%88%e5%a4%8d%e7%8e%b0","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5480\/","title":{"rendered":"mysql\u6b7b\u9501\u600e\u4e48\u590d\u73b0"},"content":{"rendered":"<blockquote><p>\n  \u6b7b\u9501\u662f\u6307\u591a\u4e2a\u8fdb\u7a0b\u4e92\u76f8\u7b49\u5f85\u800c\u65e0\u6cd5\u6267\u884c\u7684\u60c5\u51b5\u3002\u5728 mysql \u4e2d\uff0c\u6b7b\u9501\u901a\u5e38\u53d1\u751f\u5728\u66f4\u65b0\u540c\u4e00\u884c\u6216\u591a\u884c\u6570\u636e\u65f6\u3002\u590d\u73b0\u6b7b\u9501\u7684\u6b65\u9aa4\uff1a\u521b\u5efa\u6570\u636e\u8868\u5e76\u63d2\u5165\u6570\u636e\u3002\u5f00\u542f\u4e24\u4e2a\u4e8b\u52a1\u5e76\u8bbe\u7f6e\u9501\u3002\u5c1d\u8bd5\u66f4\u65b0\u540c\u4e00\u884c\u3002\u63d0\u4ea4\u4e8b\u52a1\u3002mysql \u901a\u8fc7\u56de\u6eda\u5176\u4e2d\u4e00\u4e2a\u4e8b\u52a1\u6765\u89e3\u51b3\u6b7b\u9501\u3002\u907f\u514d\u6b7b\u9501\u7684\u65b9\u6cd5\u5305\u62ec\u7f29\u77ed\u4e8b\u52a1\u65f6\u95f4\u3001\u4f7f\u7528\u76f8\u540c\u7684\u66f4\u65b0\u987a\u5e8f\u4ee5\u53ca\u4f7f\u7528\u4e50\u89c2\u5e76\u53d1\u63a7\u5236\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/29\/2024052903302978826.jpg\" class=\"aligncenter\" title=\"mysql\u6b7b\u9501\u600e\u4e48\u590d\u73b0\u63d2\u56fe\" alt=\"mysql\u6b7b\u9501\u600e\u4e48\u590d\u73b0\u63d2\u56fe\" \/><\/p>\n<p><strong>MySQL \u6b7b\u9501\u7684\u590d\u73b0<\/strong><\/p>\n<p><strong>\u6b7b\u9501\u5b9a\u4e49<\/strong><\/p>\n<p>\u6b7b\u9501\u662f\u6307\u4e24\u4e2a\u6216\u591a\u4e2a\u8fdb\u7a0b\u4e92\u76f8\u7b49\u5f85\uff0c\u6700\u7ec8\u5bfc\u81f4\u7cfb\u7edf\u65e0\u6cd5\u7ee7\u7eed\u6267\u884c\u7684\u60c5\u51b5\u3002\u5728 MySQL \u4e2d\uff0c\u6b7b\u9501\u901a\u5e38\u53d1\u751f\u5728\u591a\u4e2a\u8fdb\u7a0b\u540c\u65f6\u5c1d\u8bd5\u66f4\u65b0\u540c\u4e00\u884c\u6216\u591a\u884c\u6570\u636e\u65f6\u3002<\/p>\n<p><strong>\u5982\u4f55\u590d\u73b0\u6b7b\u9501<\/strong><\/p>\n<p>\u60a8\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u5728 MySQL \u4e2d\u590d\u73b0\u6b7b\u9501\uff1a<\/p>\n<ol>\n<li>\n<p><strong>\u521b\u5efa\u6570\u636e\u8868\uff1a<\/strong><\/p>\n<pre>CREATE TABLE test (\n  id INT NOT NULL AUTO_INCREMENT,\n  name VARCHAR(255) NOT NULL,\n  PRIMARY KEY (id)\n);<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li>\n<p><strong>\u63d2\u5165\u6570\u636e\uff1a<\/strong><\/p>\n<pre>INSERT INTO test (name) VALUES ('John');\nINSERT INTO test (name) VALUES ('Jane');<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li>\n<p><strong>\u5f00\u542f\u4e24\u4e2a\u4e8b\u52a1\uff1a<\/strong><\/p>\n<pre>BEGIN;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li>\n<p><strong>\u83b7\u53d6\u9501\uff1a<\/strong><\/p>\n<p>\u8ba9\u4e8b\u52a1 1 \u9501\u5b9a\u7b2c\u4e00\u884c\uff1a<\/p>\n<pre>UPDATE test SET name = 'John Updated' WHERE id = 1;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8ba9\u4e8b\u52a1 2 \u9501\u5b9a\u7b2c\u4e8c\u884c\uff1a<\/p>\n<pre>UPDATE test SET name = 'Jane Updated' WHERE id = 2;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li>\n<p><strong>\u5c1d\u8bd5\u66f4\u65b0\u540c\u4e00\u884c\uff1a<\/strong><\/p>\n<p>\u8ba9\u4e8b\u52a1 1 \u5c1d\u8bd5\u66f4\u65b0\u7b2c\u4e8c\u884c\uff1a<\/p>\n<pre>UPDATE test SET name = 'John Updated' WHERE id = 2;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8ba9\u4e8b\u52a1 2 \u5c1d\u8bd5\u66f4\u65b0\u7b2c\u4e00\u884c\uff1a<\/p>\n<pre>UPDATE test SET name = 'Jane Updated' WHERE id = 1;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li>\n<p><strong>\u63d0\u4ea4\u4e8b\u52a1\uff1a<\/strong><\/p>\n<pre>COMMIT;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<\/ol>\n<p>\u5982\u679c\u4e00\u5207\u6b63\u5e38\uff0c\u8fd9\u4e24\u4e2a\u4e8b\u52a1\u90fd\u4f1a\u6210\u529f\u63d0\u4ea4\u3002\u4f46\u662f\uff0c\u5982\u679c\u4e24\u4e2a\u4e8b\u52a1\u540c\u65f6\u5c1d\u8bd5\u66f4\u65b0\u540c\u4e00\u884c\uff0c\u5c31\u4f1a\u53d1\u751f\u6b7b\u9501\u3002<\/p>\n<p><strong>\u6b7b\u9501\u68c0\u6d4b<\/strong><\/p>\n<p>\u5f53\u53d1\u751f\u6b7b\u9501\u65f6\uff0cMySQL \u4f1a\u68c0\u6d4b\u5230\u5e76\u56de\u6eda\u5176\u4e2d\u4e00\u4e2a\u4e8b\u52a1\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7\u67e5\u770b\u9519\u8bef\u65e5\u5fd7\u6765\u786e\u8ba4\u6b7b\u9501\uff1a<\/p>\n<pre>  innodb_status: lock wait timeout exceeded; try restart transaction  <\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u907f\u514d\u6b7b\u9501<\/strong><\/p>\n<p>\u4e3a\u4e86\u907f\u514d\u6b7b\u9501\uff0c\u60a8\u53ef\u4ee5\u91c7\u53d6\u4ee5\u4e0b\u63aa\u65bd\uff1a<\/p>\n<ul>\n<li>\u786e\u4fdd\u4e8b\u52a1\u5c3d\u53ef\u80fd\u77ed\u3002<\/li>\n<li>\u59cb\u7ec8\u4f7f\u7528\u76f8\u540c\u7684\u987a\u5e8f\u66f4\u65b0\u8868\u3002<\/li>\n<li>\u4f7f\u7528\u4e50\u89c2\u5e76\u53d1\u63a7\u5236\uff0c\u800c\u4e0d\u662f\u60b2\u89c2\u5e76\u53d1\u63a7\u5236\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u6b7b\u9501\u600e\u4e48\u590d\u73b0\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>\u6b7b\u9501\u662f\u6307\u591a\u4e2a\u8fdb\u7a0b\u4e92\u76f8\u7b49\u5f85\u800c\u65e0\u6cd5\u6267\u884c\u7684\u60c5\u51b5\u3002\u5728 mysql \u4e2d\uff0c\u6b7b\u9501\u901a\u5e38\u53d1\u751f\u5728\u66f4\u65b0\u540c\u4e00\u884c\u6216\u591a\u884c\u6570\u636e\u65f6\u3002\u590d\u73b0\u6b7b\u9501\u7684\u6b65\u9aa4\uff1a\u521b\u5efa\u6570\u636e\u8868\u5e76\u63d2\u5165\u6570\u636e\u3002\u5f00\u542f\u4e24\u4e2a\u4e8b\u52a1\u5e76\u8bbe\u7f6e\u9501\u3002\u5c1d\u8bd5\u66f4\u65b0\u540c\u4e00\u884c\u3002\u63d0\u4ea4\u4e8b\u52a1\u3002mysql \u901a\u8fc7\u56de\u6eda\u5176\u4e2d\u4e00\u4e2a\u4e8b\u52a1\u6765\u89e3\u51b3\u6b7b\u9501\u3002\u907f\u514d\u6b7b\u9501\u7684\u65b9\u6cd5\u5305\u62ec\u7f29\u77ed\u4e8b\u52a1\u65f6\u95f4\u3001\u4f7f\u7528\u76f8\u540c\u7684\u66f4\u65b0\u987a\u5e8f\u4ee5\u53ca\u4f7f\u7528\u4e50\u89c2\u5e76\u53d1\u63a7\u5236\u3002 MySQL \u6b7b\u9501\u7684\u590d\u73b0 \u6b7b\u9501\u5b9a\u4e49 \u6b7b\u9501\u662f\u6307\u4e24\u4e2a\u6216\u591a\u4e2a\u8fdb\u7a0b\u4e92\u76f8\u7b49\u5f85\uff0c\u6700\u7ec8\u5bfc\u81f4\u7cfb\u7edf\u65e0\u6cd5\u7ee7\u7eed\u6267\u884c\u7684\u60c5\u51b5\u3002\u5728 MySQL \u4e2d\uff0c\u6b7b\u9501\u901a\u5e38\u53d1\u751f\u5728\u591a\u4e2a\u8fdb\u7a0b\u540c\u65f6\u5c1d\u8bd5\u66f4\u65b0\u540c\u4e00\u884c\u6216\u591a\u884c\u6570\u636e\u65f6\u3002 \u5982\u4f55\u590d\u73b0\u6b7b\u9501 \u60a8\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u5728 MySQL \u4e2d\u590d\u73b0\u6b7b\u9501\uff1a \u521b\u5efa\u6570\u636e\u8868\uff1a CREATE TABLE test ( id INT NOT NULL AUTO_INCREMENT, name VARCHAR(255) NOT NULL, PRIMARY KEY (id) ); \u767b\u5f55\u540e\u590d\u5236 \u63d2\u5165\u6570\u636e\uff1a INSERT INTO test (name) VALUES (&#8216;John&#8217;); INSERT INTO test (name) VALUES (&#8216;Jane&#8217;); \u767b\u5f55\u540e\u590d\u5236 \u5f00\u542f\u4e24\u4e2a\u4e8b\u52a1\uff1a BEGIN; \u767b\u5f55\u540e\u590d\u5236 \u83b7\u53d6\u9501\uff1a \u8ba9\u4e8b\u52a1 1 \u9501\u5b9a\u7b2c\u4e00\u884c\uff1a UPDATE [&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-5480","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5480","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=5480"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5480\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5480"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5480"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5480"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}