{"id":6924,"date":"2024-11-14T09:58:08","date_gmt":"2024-11-14T01:58:08","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6924\/"},"modified":"2024-11-14T09:58:08","modified_gmt":"2024-11-14T01:58:08","slug":"springboot-%e9%a1%b9%e7%9b%ae%e4%b8%ad-mysql-%e6%97%a5%e6%9c%9f%e5%ad%97%e6%ae%b5%e8%8e%ab%e5%90%8d%e5%8f%98%e4%b8%ba-null-%e5%a6%82%e4%bd%95%e6%8e%92%e6%9f%a5%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6924\/","title":{"rendered":"SpringBoot \u9879\u76ee\u4e2d MySQL \u65e5\u671f\u5b57\u6bb5\u83ab\u540d\u53d8\u4e3a null \u5982\u4f55\u6392\u67e5\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173009193739322.jpg\" class=\"aligncenter\" title=\"SpringBoot \u9879\u76ee\u4e2d MySQL \u65e5\u671f\u5b57\u6bb5\u83ab\u540d\u53d8\u4e3a null \u5982\u4f55\u6392\u67e5\uff1f\u63d2\u56fe\" alt=\"SpringBoot \u9879\u76ee\u4e2d MySQL \u65e5\u671f\u5b57\u6bb5\u83ab\u540d\u53d8\u4e3a null \u5982\u4f55\u6392\u67e5\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>MySQL \u8868\u4e2d\u65e5\u671f\u5b57\u6bb5\u83ab\u540d\u53d8\u4e3a null \u7684\u6392\u67e5\u65b9\u6cd5<\/strong><\/p>\n<p>\u5728\u4f7f\u7528 SpringBoot \u548c MySQL 5.7 \u7684\u9879\u76ee\u4e2d\uff0c\u7528\u6237\u53d1\u73b0\u8868\u4e2d\u67d0\u4e2a\u65e5\u671f\u5b57\u6bb5\u7684\u503c\u4f1a\u65e0\u6545\u53d8\u4e3a null\u3002\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u672c\u6587\u5c06\u63d0\u4f9b\u4ee5\u4e0b\u6392\u67e5\u65b9\u6cd5\uff1a<\/p>\n<p><strong>1. \u4f7f\u7528 binlog \u76d1\u63a7<\/strong><\/p>\n<p>MySQL \u7684 binlog \u8bb0\u5f55\u4e86\u6570\u636e\u5e93\u4e2d\u6240\u6709\u5df2\u6267\u884c\u7684\u5199\u64cd\u4f5c\u3002\u4f60\u53ef\u4ee5\u67e5\u770b binlog\uff0c\u6839\u636e\u5173\u952e\u8bcd\u67e5\u627e\u5c06\u5b57\u6bb5\u4fee\u6539\u4e3a null \u7684 SQL \u8bed\u53e5\u3002<\/p>\n<p><strong>\u5177\u4f53\u6b65\u9aa4\uff1a<\/strong><\/p>\n<ol>\n<li>\u542f\u7528 binlog\uff1a\u5728 MySQL \u914d\u7f6e\u6587\u4ef6\u4e2d\u6dfb\u52a0 log_bin=ON \u5e76\u91cd\u542f MySQL\u3002<\/li>\n<li>\u67e5\u627e binlog \u6587\u4ef6\uff1a\u901a\u5e38\u4f4d\u4e8e \/var\/log\/\/ \u76ee\u5f55\u4e0b\u3002<\/li>\n<li>\u4f7f\u7528 grep \u547d\u4ee4\u67e5\u627e\u4fee\u6539\u8bed\u53e5\uff1a\u4f8b\u5982\uff0cgrep &#8216;UPDATE =NULL&#8217;\u3002\n<p>\u901a\u8fc7\u5b9a\u4f4d\u4fee\u6539\u8bed\u53e5\uff0c\u4f60\u53ef\u4ee5\u4e86\u89e3\u5230\u5728\u54ea\u4e2a\u73af\u8282\u5bfc\u81f4\u4e86\u5b57\u6bb5\u503c\u53d8\u4e3a null\u3002<\/p>\n<p><strong>2. \u5176\u4ed6\u6392\u67e5\u65b9\u6cd5<\/strong><\/p>\n<p>\u9664\u4e86 binlog \u76d1\u63a7\u5916\uff0c\u8fd8\u53ef\u4ee5\u8003\u8651\u4ee5\u4e0b\u65b9\u6cd5\uff1a<\/p>\n<ul>\n<li> <strong>\u4ee3\u7801\u5ba1\u67e5\uff1a<\/strong> \u4ed4\u7ec6\u5ba1\u67e5\u4ee3\u7801\u4e2d\u53ef\u80fd\u5bfc\u81f4 null \u503c\u7684\u903b\u8f91\u3002<\/li>\n<li> <strong>\u8c03\u8bd5\uff1a<\/strong> \u5728\u53ef\u7591\u4ee3\u7801\u6bb5\u9644\u8fd1\u653e\u7f6e\u65ad\u70b9\uff0c\u4ee5\u8c03\u8bd5\u7a0b\u5e8f\u5e76\u67e5\u627e\u5bfc\u81f4 null \u503c\u7684\u539f\u56e0\u3002<\/li>\n<li> <strong>\u6570\u636e\u5e93\u5ba1\u8ba1\uff1a<\/strong> \u4f7f\u7528 MySQL \u6570\u636e\u5e93\u5ba1\u8ba1\u5de5\u5177\uff08\u4f8b\u5982\uff0c\u5ba1\u8ba1\u63d2\u4ef6\uff09\u6765\u8ddf\u8e2a\u5bf9\u8868\u7684\u4fee\u6539\u64cd\u4f5c\u3002<\/li>\n<\/ul>\n<table>\n    SET<br \/>\n  <\/table>\n<\/li>\n<\/ol>\n<p>\u4ee5\u4e0a\u5c31\u662fSpringBoot \u9879\u76ee\u4e2d MySQL \u65e5\u671f\u5b57\u6bb5\u83ab\u540d\u53d8\u4e3a null \u5982\u4f55\u6392\u67e5\uff1f\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 \u8868\u4e2d\u65e5\u671f\u5b57\u6bb5\u83ab\u540d\u53d8\u4e3a null \u7684\u6392\u67e5\u65b9\u6cd5 \u5728\u4f7f\u7528 SpringBoot \u548c MySQL 5.7 \u7684\u9879\u76ee\u4e2d\uff0c\u7528\u6237\u53d1\u73b0\u8868\u4e2d\u67d0\u4e2a\u65e5\u671f\u5b57\u6bb5\u7684\u503c\u4f1a\u65e0\u6545\u53d8\u4e3a null\u3002\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u672c\u6587\u5c06\u63d0\u4f9b\u4ee5\u4e0b\u6392\u67e5\u65b9\u6cd5\uff1a 1. \u4f7f\u7528 binlog \u76d1\u63a7 MySQL \u7684 binlog \u8bb0\u5f55\u4e86\u6570\u636e\u5e93\u4e2d\u6240\u6709\u5df2\u6267\u884c\u7684\u5199\u64cd\u4f5c\u3002\u4f60\u53ef\u4ee5\u67e5\u770b binlog\uff0c\u6839\u636e\u5173\u952e\u8bcd\u67e5\u627e\u5c06\u5b57\u6bb5\u4fee\u6539\u4e3a null \u7684 SQL \u8bed\u53e5\u3002 \u5177\u4f53\u6b65\u9aa4\uff1a \u542f\u7528 binlog\uff1a\u5728 MySQL \u914d\u7f6e\u6587\u4ef6\u4e2d\u6dfb\u52a0 log_bin=ON \u5e76\u91cd\u542f MySQL\u3002 \u67e5\u627e binlog \u6587\u4ef6\uff1a\u901a\u5e38\u4f4d\u4e8e \/var\/log\/\/ \u76ee\u5f55\u4e0b\u3002 \u4f7f\u7528 grep \u547d\u4ee4\u67e5\u627e\u4fee\u6539\u8bed\u53e5\uff1a\u4f8b\u5982\uff0cgrep &#8216;UPDATE =NULL&#8217;\u3002 \u901a\u8fc7\u5b9a\u4f4d\u4fee\u6539\u8bed\u53e5\uff0c\u4f60\u53ef\u4ee5\u4e86\u89e3\u5230\u5728\u54ea\u4e2a\u73af\u8282\u5bfc\u81f4\u4e86\u5b57\u6bb5\u503c\u53d8\u4e3a null\u3002 2. \u5176\u4ed6\u6392\u67e5\u65b9\u6cd5 \u9664\u4e86 binlog \u76d1\u63a7\u5916\uff0c\u8fd8\u53ef\u4ee5\u8003\u8651\u4ee5\u4e0b\u65b9\u6cd5\uff1a \u4ee3\u7801\u5ba1\u67e5\uff1a \u4ed4\u7ec6\u5ba1\u67e5\u4ee3\u7801\u4e2d\u53ef\u80fd\u5bfc\u81f4 null \u503c\u7684\u903b\u8f91\u3002 \u8c03\u8bd5\uff1a \u5728\u53ef\u7591\u4ee3\u7801\u6bb5\u9644\u8fd1\u653e\u7f6e\u65ad\u70b9\uff0c\u4ee5\u8c03\u8bd5\u7a0b\u5e8f\u5e76\u67e5\u627e\u5bfc\u81f4 [&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-6924","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6924","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=6924"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6924\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6924"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6924"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6924"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}