{"id":26942,"date":"2024-11-24T10:49:04","date_gmt":"2024-11-24T02:49:04","guid":{"rendered":"https:\/\/fwq.ai\/blog\/26942\/"},"modified":"2024-11-24T10:49:04","modified_gmt":"2024-11-24T02:49:04","slug":"pycharm-%e4%b8%ad-django-%e8%bf%81%e7%a7%bb%e5%87%ba%e9%94%99%ef%bc%9a%e5%a6%82%e4%bd%95%e8%a7%a3%e5%86%b3django-db-utils-operationalerror-ssl-connection-error%ef%bc%9f-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/26942\/","title":{"rendered":"PyCharm \u4e2d Django \u8fc1\u79fb\u51fa\u9519\uff1a\u5982\u4f55\u89e3\u51b3&#8221;django.db.utils.OperationalError: SSL connection error&#8221;\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173113295123019.jpg\" class=\"aligncenter\" title=\"PyCharm \u4e2d Django \u8fc1\u79fb\u51fa\u9519\uff1a\u5982\u4f55\u89e3\u51b3&#8221;django.db.utils.OperationalError: SSL connection error&#8221;\uff1f\u63d2\u56fe\" alt=\"PyCharm \u4e2d Django \u8fc1\u79fb\u51fa\u9519\uff1a\u5982\u4f55\u89e3\u51b3&#8221;django.db.utils.OperationalError: SSL connection error&#8221;\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong> \u4e2d django \u8fd0\u884c\u8fc1\u79fb\u6307\u4ee4\u65f6\u51fa\u9519\uff1adjango.db.utils.operationalerror<\/strong><\/p>\n<p>\u5728\u4f7f\u7528 django \u65f6\uff0c\u5728 pycharm \u4e2d\u8fd0\u884c &#8221; manage.py migrate&#8221; \u6307\u4ee4\uff0c\u53ef\u80fd\u51fa\u73b0 &#8220;django.db.utils.operationalerror&#8221; \u9519\u8bef\u3002<\/p>\n<p><strong>\u95ee\u9898\u63cf\u8ff0<\/strong><\/p>\n<p>\u62a5\u9519\u4fe1\u606f\u4e3a\uff1a&#8221;db._exceptions.operationalerror: (2026, &#8216;ssl connection error: unknown error number&#8217;)&#8221;\u3002\u8fd9\u901a\u5e38\u662f\u7531\u4e8e\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668\u7684 ssl \u8bbe\u7f6e\u4e0d\u5339\u914d\u9020\u6210\u7684\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848<\/strong><\/p>\n<p>\u8981\u89e3\u51b3\u6b64\u95ee\u9898\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u4ee5\u4e0b\u65b9\u6cd5\uff1a<\/p>\n<ul>\n<li><strong>\u5728 mysql \u670d\u52a1\u5668\u914d\u7f6e\u6587\u4ef6\u4e2d\u6dfb\u52a0 &#8220;skip_ssl&#8221;<\/strong><\/li>\n<\/ul>\n<p>\u5728 mysql \u670d\u52a1\u5668\u914d\u7f6e\u6587\u4ef6\uff08\u901a\u5e38\u4e3a my.cnf\uff09\u7684 [mysqld] \u90e8\u5206\u4e0b\uff0c\u6dfb\u52a0\u5982\u4e0b\u884c\uff1a<\/p>\n<pre>skip_ssl<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li><strong>\u9a8c\u8bc1 mysqlclient \u662f\u5426\u652f\u6301\u5b89\u5168\u8fde\u63a5<\/strong><\/li>\n<\/ul>\n<p>\u786e\u4fdd mysqlclient \u7248\u672c\u652f\u6301\u4e0e mysql \u670d\u52a1\u5668\u7684\u5b89\u5168\u8fde\u63a5\u3002\u5982\u679c\u662f\uff0c\u8bf7\u914d\u7f6e\u4ee5\u4e0b\u8bbe\u7f6e\uff1a<\/p>\n<pre>options = {\n    'ssl_ca': '\/path\/to\/ca.pem',\n    'ssl_key': '\/path\/to\/key.pem',\n    'ssl_cert': '\/path\/to\/cert.pem',\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li><strong>\u5176\u4ed6\u53ef\u80fd\u7684\u89e3\u51b3\u65b9\u6848<\/strong><\/li>\n<\/ul>\n<p>\u5982\u679c\u4ee5\u4e0a\u89e3\u51b3\u65b9\u6848\u4e0d\u8d77\u4f5c\u7528\uff0c\u8fd8\u53ef\u4ee5\u5c1d\u8bd5\u4ee5\u4e0b\u65b9\u6cd5\uff1a<\/p>\n<pre>*\u91cd\u542f MySQL \u670d\u52a1\u5668\n*\u786e\u4fdd\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668\u4f7f\u7528\u76f8\u540c\u7684\u7528\u6237\u548c\u5bc6\u7801\n*\u68c0\u67e5\u9632\u706b\u5899\u8bbe\u7f6e\n*\u68c0\u67e5\u7aef\u53e3\u662f\u5426\u5df2\u5f00\u653e\n<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6839\u636e\u60a8\u7684\u5177\u4f53\u60c5\u51b5\uff0c\u8fd9\u4e9b\u89e3\u51b3\u65b9\u6848\u53ef\u80fd\u4f1a\u89e3\u51b3 &#8220;django.db.utils.operationalerror&#8221; \u9519\u8bef\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fPyCharm \u4e2d Django \u8fc1\u79fb\u51fa\u9519\uff1a\u5982\u4f55\u89e3\u51b3&#8221;django.db.utils.OperationalError: SSL connection error&#8221;\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>\u4e2d django \u8fd0\u884c\u8fc1\u79fb\u6307\u4ee4\u65f6\u51fa\u9519\uff1adjango.db.utils.operationalerror \u5728\u4f7f\u7528 django \u65f6\uff0c\u5728 pycharm \u4e2d\u8fd0\u884c &#8221; manage.py migrate&#8221; \u6307\u4ee4\uff0c\u53ef\u80fd\u51fa\u73b0 &#8220;django.db.utils.operationalerror&#8221; \u9519\u8bef\u3002 \u95ee\u9898\u63cf\u8ff0 \u62a5\u9519\u4fe1\u606f\u4e3a\uff1a&#8221;db._exceptions.operationalerror: (2026, &#8216;ssl connection error: unknown error number&#8217;)&#8221;\u3002\u8fd9\u901a\u5e38\u662f\u7531\u4e8e\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668\u7684 ssl \u8bbe\u7f6e\u4e0d\u5339\u914d\u9020\u6210\u7684\u3002 \u89e3\u51b3\u65b9\u6848 \u8981\u89e3\u51b3\u6b64\u95ee\u9898\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u4ee5\u4e0b\u65b9\u6cd5\uff1a \u5728 mysql \u670d\u52a1\u5668\u914d\u7f6e\u6587\u4ef6\u4e2d\u6dfb\u52a0 &#8220;skip_ssl&#8221; \u5728 mysql \u670d\u52a1\u5668\u914d\u7f6e\u6587\u4ef6\uff08\u901a\u5e38\u4e3a my.cnf\uff09\u7684 [mysqld] \u90e8\u5206\u4e0b\uff0c\u6dfb\u52a0\u5982\u4e0b\u884c\uff1a skip_ssl \u767b\u5f55\u540e\u590d\u5236 \u9a8c\u8bc1 mysqlclient \u662f\u5426\u652f\u6301\u5b89\u5168\u8fde\u63a5 \u786e\u4fdd mysqlclient \u7248\u672c\u652f\u6301\u4e0e mysql \u670d\u52a1\u5668\u7684\u5b89\u5168\u8fde\u63a5\u3002\u5982\u679c\u662f\uff0c\u8bf7\u914d\u7f6e\u4ee5\u4e0b\u8bbe\u7f6e\uff1a options = { &#8216;ssl_ca&#8217;: &#8216;\/path\/to\/ca.pem&#8217;, &#8216;ssl_key&#8217;: &#8216;\/path\/to\/key.pem&#8217;, &#8216;ssl_cert&#8217;: [&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-26942","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/26942","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=26942"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/26942\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=26942"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=26942"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=26942"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}