{"id":7618,"date":"2024-11-14T13:13:28","date_gmt":"2024-11-14T05:13:28","guid":{"rendered":"https:\/\/fwq.ai\/blog\/7618\/"},"modified":"2024-11-14T13:13:28","modified_gmt":"2024-11-14T05:13:28","slug":"django-%e9%a1%b9%e7%9b%ae%e8%bf%90%e8%a1%8c-python-manage-py-migrate-%e6%8a%a5%e9%94%99-django-db-utils-operationalerror-2026-ssl-connection-error-unknown-error-number-%e5%a6%82","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/7618\/","title":{"rendered":"Django \u9879\u76ee\u8fd0\u884c &#8220;python manage.py migrate&#8221; \u62a5\u9519 &#8220;django.db.utils.OperationalError: (2026, &#8216;SSL connection error: unknown error number&#8217;)&#8221; \u5982\u4f55\u89e3\u51b3\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173105982370849.jpg\" class=\"aligncenter\" title=\"Django \u9879\u76ee\u8fd0\u884c &#8220;python manage.py migrate&#8221; \u62a5\u9519 &#8220;django.db.utils.OperationalError: (2026, &#8216;SSL connection error: unknown error number&#8217;)&#8221; \u5982\u4f55\u89e3\u51b3\uff1f\u63d2\u56fe\" alt=\"Django \u9879\u76ee\u8fd0\u884c &#8220;python manage.py migrate&#8221; \u62a5\u9519 &#8220;django.db.utils.OperationalError: (2026, &#8216;SSL connection error: unknown error number&#8217;)&#8221; \u5982\u4f55\u89e3\u51b3\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong> \u4e2d django \u8fd0\u884c &#8221; manage.py migrate&#8221; \u62a5\u9519 &#8220;django.db.utils.operationalerror&#8221;<\/strong><\/p>\n<p>\u5728\u4f7f\u7528 python 3.7.4\u3001django 3.2.19 \u548c client 1.4.6 \u5f00\u53d1 django \u9879\u76ee\u65f6\uff0c\u4f60\u9047\u5230\u4e86\u4e00\u4e2a\u95ee\u9898\u3002\u5728 pycharm \u7ec8\u7aef\u4e2d\uff0c\u8fd0\u884c &#8220;python manage.py makemigrations&#8221; \u547d\u4ee4\u53ef\u4ee5\u6b63\u5e38\u6267\u884c\uff0c\u4f46\u8fd0\u884c &#8220;python manage.py migrate&#8221; \u547d\u4ee4\u5374\u62a5\u9519 &#8220;mysqldb._exceptions.operationalerror: (2026, &#8216;ssl connection error: unknown error number&#8217;)\u201d\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6cd5\uff1a<\/strong><\/p>\n<p>\u51fa\u73b0\u8fd9\u79cd\u60c5\u51b5\uff0c\u53ef\u80fd\u662f\u56e0\u4e3a\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668\u5bf9 ssl \u8fde\u63a5\u7684\u914d\u7f6e\u4e0d\u4e00\u81f4\u3002\u8981\u89e3\u51b3\u6b64\u95ee\u9898\uff0c\u4f60\u53ef\u4ee5\u91c7\u53d6\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<ul>\n<li>\u5728 mysql \u670d\u52a1\u5668\u7684\u914d\u7f6e\u6587\u4ef6\uff08\u901a\u5e38\u4f4d\u4e8e \/etc\/mysql\/my.cnf\uff09\u4e2d\u7684 [mysqld] \u90e8\u5206\u4e0b\u6dfb\u52a0 &#8220;skip_ssl&#8221;\uff0c\u4f7f\u5176\u5916\u89c2\u7c7b\u4f3c\u4e8e\uff1a<\/li>\n<\/ul>\n<pre>[mysqld]\nskip_ssl<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li>\u9a8c\u8bc1 mysqlclient \u662f\u5426\u652f\u6301\u5b89\u5168\u8fde\u63a5\u3002\u5982\u679c\u652f\u6301\uff0c\u5219\u5728 django \u9879\u76ee\u7684 settings.py \u6587\u4ef6\u4e2d\u8fdb\u884c\u76f8\u5e94\u914d\u7f6e\uff0c\u5982\u4e0b\uff1a<\/li>\n<\/ul>\n<pre>DATABASES = {\n    'default': {\n        'ENGINE': 'django.db.backends.mysql',\n        'NAME': 'your_database_name',\n        'USER': 'your_database_user',\n        'PASSWORD': 'your_database_password',\n        'HOST': 'your_database_host',\n        'PORT': 'your_database_port',\n        'OPTIONS': {\n            'sslmode': 'verify-ca',\n            'cafile': 'path\/to\/your\/certificate'\n        }\n    }\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u901a\u8fc7\u8fd9\u4e9b\u914d\u7f6e\uff0c\u4f60\u5e94\u8be5\u80fd\u591f\u5728 pycharm \u4e2d\u6210\u529f\u8fd0\u884c &#8220;python manage.py migrate&#8221; \u547d\u4ee4\u4e86\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fDjango \u9879\u76ee\u8fd0\u884c &#8221; manage.py migrate&#8221; \u62a5\u9519 &#8220;django.db.utils.OperationalError: (2026, &#8216;SSL connection error: unknown error number&#8217;)&#8221; \u5982\u4f55\u89e3\u51b3\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>\u4e2d django \u8fd0\u884c &#8221; manage.py migrate&#8221; \u62a5\u9519 &#8220;django.db.utils.operationalerror&#8221; \u5728\u4f7f\u7528 python 3.7.4\u3001django 3.2.19 \u548c client 1.4.6 \u5f00\u53d1 django \u9879\u76ee\u65f6\uff0c\u4f60\u9047\u5230\u4e86\u4e00\u4e2a\u95ee\u9898\u3002\u5728 pycharm \u7ec8\u7aef\u4e2d\uff0c\u8fd0\u884c &#8220;python manage.py makemigrations&#8221; \u547d\u4ee4\u53ef\u4ee5\u6b63\u5e38\u6267\u884c\uff0c\u4f46\u8fd0\u884c &#8220;python manage.py migrate&#8221; \u547d\u4ee4\u5374\u62a5\u9519 &#8220;mysqldb._exceptions.operationalerror: (2026, &#8216;ssl connection error: unknown error number&#8217;)\u201d\u3002 \u89e3\u51b3\u65b9\u6cd5\uff1a \u51fa\u73b0\u8fd9\u79cd\u60c5\u51b5\uff0c\u53ef\u80fd\u662f\u56e0\u4e3a\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668\u5bf9 ssl \u8fde\u63a5\u7684\u914d\u7f6e\u4e0d\u4e00\u81f4\u3002\u8981\u89e3\u51b3\u6b64\u95ee\u9898\uff0c\u4f60\u53ef\u4ee5\u91c7\u53d6\u4ee5\u4e0b\u6b65\u9aa4\uff1a \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u5728 mysql \u670d\u52a1\u5668\u7684\u914d\u7f6e\u6587\u4ef6\uff08\u901a\u5e38\u4f4d\u4e8e \/etc\/mysql\/my.cnf\uff09\u4e2d\u7684 [mysqld] \u90e8\u5206\u4e0b\u6dfb\u52a0 &#8220;skip_ssl&#8221;\uff0c\u4f7f\u5176\u5916\u89c2\u7c7b\u4f3c\u4e8e\uff1a [mysqld] skip_ssl \u767b\u5f55\u540e\u590d\u5236 \u9a8c\u8bc1 mysqlclient \u662f\u5426\u652f\u6301\u5b89\u5168\u8fde\u63a5\u3002\u5982\u679c\u652f\u6301\uff0c\u5219\u5728 django [&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-7618","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7618","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=7618"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7618\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=7618"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=7618"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=7618"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}