{"id":6716,"date":"2022-01-09T20:34:47","date_gmt":"2022-01-09T20:34:47","guid":{"rendered":"https:\/\/blog.gwlin.com\/?p=6716"},"modified":"2023-04-01T03:36:37","modified_gmt":"2023-04-01T03:36:37","slug":"mysql \u5907\u4efd\u590d\u539f \u9047\u5230 Cannot add foreign key constraint","status":"publish","type":"post","link":"https:\/\/www.gwlin.com\/blog\/posts\/6716","title":{"rendered":"mysql \u5907\u4efd\u590d\u539f \u9047\u5230 Cannot add foreign key constraint"},"content":{"rendered":"<p>\u7535\u8111\u91cd\u88c5\u540e\u8981\u91cd\u65b0\u642d\u5efa\u73af\u5883\uff0c\u5bfc\u5165mysql\u5907\u4efd\u6570\u636e\u7684\u65f6\u5019\u9047\u5230&nbsp;<font color=\"#c24f4a\">ERROR 1215 (HY000) at line 72: Cannot add foreign key constraint<\/font> \u9519\u8bef\uff0c\u8fd8\u6709\u6700\u540e\u4e00\u5806 XX \u8bbe\u7f6e\u4e0d\u80fd\u4e3anull\u7684\u63d0\u793a\uff0c\u5982 <font color=\"#c24f4a\">Variable 'time_zone' can't be set to the value of 'NULL'<\/font>\u3002<\/p>\n<p>\u7f51\u4e0a\u5927\u591a\u6570\u90fd\u8bf4\u8981\u505c\u7528\u5916\u952e\u68c0\u67e5&nbsp;<font color=\"#c24f4a\">SET FOREIGN_KEY_CHECKS = 0<\/font>\uff0c\u6216\u8005\u68c0\u67e5\u5916\u952e\u7684\u6570\u636e\u7c7b\u578b\uff0c\u8868\u7684\u5b57\u7b26\u96c6\u7b49\u7b49\uff0c\u5168\u90fd\u8bd5\u4e86\u4e00\u904d\uff0c\u6ca1\u7528\u3002<\/p>\n<p>\u5076\u7136\u70b9\u8fdb\u4e00\u7bc7<a href=\"https:\/\/programmerah.com\/solve-error-1231-42000-variabletime_zone-cant-28591\/\" target=\"_blank\">\u535a\u5ba2<\/a>\uff0c\u8bf4\u628a <font color=\"#c24f4a\">max_allowed_packet<\/font> \u8c03\u9ad8\uff0c\u6b7b\u9a6c\u5f53\u6d3b\u9a6c\u533b\uff0c\u75c5\u6025\u4e71\u6295\u533b\uff0c\u8bd5\u8bd5\u5c31\u8bd5\u8bd5\u3002<\/p>\n<p>\u5c45\u7136\u6210\u4e86\u3002<\/p>\n<p>\u5b8c\u5168\u4e0d\u77e5\u9053\u4e3a\u4ec0\u4e48\u5305\u7684\u5927\u5c0f\u548c\u5916\u952e\u3001\u8bbe\u7f6e\u6709\u4ec0\u4e48\u5173\u7cfb\uff0c\u4e0d\u8fc7\u61d2\u5f97\u7406\u90a3\u4e48\u591a\u4e86\uff0c\u8fd9\u91cc\u8bb0\u4e0b\u6765\uff0c\u65b9\u4fbf\u540c\u6837\u9047\u5230\u8fd9\u4e2a\u95ee\u9898\u7684\u4eba\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u628a max_allowed_packet \u8c03\u9ad8<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[179],"tags":[],"class_list":["post-6716","post","type-post","status-publish","format-standard","hentry","category-notes"],"_links":{"self":[{"href":"https:\/\/www.gwlin.com\/blog\/wp-json\/wp\/v2\/posts\/6716","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gwlin.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gwlin.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gwlin.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gwlin.com\/blog\/wp-json\/wp\/v2\/comments?post=6716"}],"version-history":[{"count":0,"href":"https:\/\/www.gwlin.com\/blog\/wp-json\/wp\/v2\/posts\/6716\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.gwlin.com\/blog\/wp-json\/wp\/v2\/media?parent=6716"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gwlin.com\/blog\/wp-json\/wp\/v2\/categories?post=6716"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gwlin.com\/blog\/wp-json\/wp\/v2\/tags?post=6716"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}