{"id":26691,"date":"2024-11-24T15:43:43","date_gmt":"2024-11-24T07:43:43","guid":{"rendered":"https:\/\/fwq.ai\/blog\/26691\/"},"modified":"2024-11-24T15:43:43","modified_gmt":"2024-11-24T07:43:43","slug":"c%e8%af%ad%e8%a8%80%e6%93%8d%e4%bd%9cmysql%e5%87%ba%e7%8e%b0commands-out-of-sync%e9%94%99%e8%af%af%ef%bc%9a%e5%a6%82%e4%bd%95%e8%a7%a3%e5%86%b3%e5%b9%b6%e5%8f%91%e9%97%ae%e9%a2%98-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/26691\/","title":{"rendered":"C\u8bed\u8a00\u64cd\u4f5cMySQL\u51fa\u73b0\u201cCommands out of sync\u201d\u9519\u8bef\uff1a\u5982\u4f55\u89e3\u51b3\u5e76\u53d1\u95ee\u9898\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173104597258382.jpg\" class=\"aligncenter\" title=\"C\u8bed\u8a00\u64cd\u4f5cMySQL\u51fa\u73b0\u201cCommands out of sync\u201d\u9519\u8bef\uff1a\u5982\u4f55\u89e3\u51b3\u5e76\u53d1\u95ee\u9898\uff1f\u63d2\u56fe\" alt=\"C\u8bed\u8a00\u64cd\u4f5cMySQL\u51fa\u73b0\u201cCommands out of sync\u201d\u9519\u8bef\uff1a\u5982\u4f55\u89e3\u51b3\u5e76\u53d1\u95ee\u9898\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u64cd\u4f5c\u9047\u5230\u201c[2014]: commands out of sync; you can&#8217;t run this command now\u201d\u95ee\u9898<\/strong><\/p>\n<p><strong>\u95ee\u9898\u8be6\u60c5\uff1a<\/strong><\/p>\n<p>\u5728c\u8bed\u8a00\u64cd\u4f5cmysql\u65f6\uff0c\u9047\u5230\u4e86\u5982\u9898\u6240\u8ff0\u7684\u9519\u8bef\u3002\u8be5\u9519\u8bef\u5bfc\u81f4\u540e\u7eed\u7684\u6240\u6709sql\u547d\u4ee4\u90fd\u65e0\u6cd5\u6267\u884c\u3002\u95ee\u9898\u53ef\u4ee5\u901a\u8fc7\u5feb\u901f\u6267\u884c\u591a\u6b21\u524d\u7aef\u64cd\u4f5c\u6765\u89e6\u53d1\u3002<\/p>\n<p><strong>\u9519\u8bef\u65e5\u5fd7\u793a\u4f8b\uff1a<\/strong><\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<pre>23-05-05 11:30:20 | info | mysqlquery.success | sql: select * from tb_video where id='0105a290';\n23-05-05 11:30:20 | error | video selectone | mysql store result failed | err[0]:\n23-05-05 11:30:20 | error | mysqlquery.err | sql: select * from tb_video where id='6d1db3db';\n23-05-05 11:30:27 | error | mysqlquery.err | err[2014]: commands out of sync; you can't run this command now<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6cd5\uff1a<\/strong><\/p>\n<p>\u4ece\u65e5\u5fd7\u4e0a\u770b\uff0c\u95ee\u9898\u51fa\u73b0\u5728 updatevideoview \u51fd\u6570\u4e2d\uff0c\u5728\u6267\u884c select \u8bed\u53e5\u540e\u53c8\u8fdb\u884c\u4e86 update \u64cd\u4f5c\u3002\u8fd9\u5bfc\u81f4\u4e86\u5e76\u53d1\u95ee\u9898\uff0c\u4f7f\u5f97\u540e\u7eed\u7684 select \u8bed\u53e5\u65e0\u6cd5\u6b63\u5e38\u6267\u884c\u3002<\/p>\n<p>\u4e3a\u4e86\u89e3\u51b3\u8be5\u95ee\u9898\uff0c\u9700\u8981\u5728 updatevideoview \u51fd\u6570\u4e2d\u6dfb\u52a0\u5982\u4e0b\u9501\uff1a<\/p>\n<pre>void UpdateVideoView(std::string id) {\n  std::lock_guard&lt;std::mutex&gt; lock(_mutex);\n  MysqlQuery query;\n  if (!query.Query(\"UPDATE tb_views SET view=view+1 WHERE id='%s'\", id.c_str())) {\n    return;\n  }\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u901a\u8fc7\u6dfb\u52a0\u9501\uff0c\u53ef\u4ee5\u786e\u4fdd\u5728\u6267\u884c update \u8bed\u53e5\u4e4b\u524d\uff0c\u6ca1\u6709\u5176\u4ed6\u7ebf\u7a0b\u6b63\u5728\u6267\u884c select \u8bed\u53e5\uff0c\u4ece\u800c\u907f\u514d\u4e86\u5e76\u53d1\u95ee\u9898\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fC\u8bed\u8a00\u64cd\u4f5cMySQL\u51fa\u73b0\u201cCommands out of sync\u201d\u9519\u8bef\uff1a\u5982\u4f55\u89e3\u51b3\u5e76\u53d1\u95ee\u9898\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u64cd\u4f5c\u9047\u5230\u201c[2014]: commands out of sync; you can&#8217;t run this command now\u201d\u95ee\u9898 \u95ee\u9898\u8be6\u60c5\uff1a \u5728c\u8bed\u8a00\u64cd\u4f5cmysql\u65f6\uff0c\u9047\u5230\u4e86\u5982\u9898\u6240\u8ff0\u7684\u9519\u8bef\u3002\u8be5\u9519\u8bef\u5bfc\u81f4\u540e\u7eed\u7684\u6240\u6709sql\u547d\u4ee4\u90fd\u65e0\u6cd5\u6267\u884c\u3002\u95ee\u9898\u53ef\u4ee5\u901a\u8fc7\u5feb\u901f\u6267\u884c\u591a\u6b21\u524d\u7aef\u64cd\u4f5c\u6765\u89e6\u53d1\u3002 \u9519\u8bef\u65e5\u5fd7\u793a\u4f8b\uff1a \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b 23-05-05 11:30:20 | info | mysqlquery.success | sql: select * from tb_video where id=&#8217;0105a290&#8242;; 23-05-05 11:30:20 | error | video selectone | mysql store result failed | err[0]: 23-05-05 11:30:20 | error | mysqlquery.err | sql: select * from tb_video [&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-26691","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/26691","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=26691"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/26691\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=26691"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=26691"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=26691"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}