{"id":7616,"date":"2024-11-14T08:20:26","date_gmt":"2024-11-14T00:20:26","guid":{"rendered":"https:\/\/fwq.ai\/blog\/7616\/"},"modified":"2024-11-14T08:20:26","modified_gmt":"2024-11-14T00:20:26","slug":"django-%e9%a1%b9%e7%9b%ae%e8%bf%90%e8%a1%8c%e6%97%b6%e6%8a%a5%e9%94%99django-core-exceptions-improperlyconfigured-django-db-backends-mysql-isnt-an-available-database-backend","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/7616\/","title":{"rendered":"Django \u9879\u76ee\u8fd0\u884c\u65f6\u62a5\u9519\u201cdjango.core.exceptions.ImproperlyConfigured: &#8216;django.db.backends.mysql&#8217; isn&#8217;t an available database backend\u201d\uff0c\u5982\u4f55\u89e3\u51b3\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173105964485627.jpg\" class=\"aligncenter\" title=\"Django \u9879\u76ee\u8fd0\u884c\u65f6\u62a5\u9519\u201cdjango.core.exceptions.ImproperlyConfigured: &#8216;django.db.backends.mysql&#8217; isn&#8217;t an available database backend\u201d\uff0c\u5982\u4f55\u89e3\u51b3\uff1f\u63d2\u56fe\" alt=\"Django \u9879\u76ee\u8fd0\u884c\u65f6\u62a5\u9519\u201cdjango.core.exceptions.ImproperlyConfigured: &#8216;django.db.backends.mysql&#8217; isn&#8217;t an available database backend\u201d\uff0c\u5982\u4f55\u89e3\u51b3\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u8fd0\u884c django \u9879\u76ee\u65f6\u201cdjango.ore.exceptions.improperlyconfigured\u201d\u9519\u8bef<\/strong><\/p>\n<p>\u9879\u76ee\u5728\u8fd0\u884c\u65f6\u51fa\u73b0\u4e86\u5982\u4e0b\u9519\u8bef\uff1a<\/p>\n<pre>django.core.exceptions.improperlyconfigured: 'django.db.backends.mysql' isn't an available database backend or couldn't be imported. check the above exception. to use one of the built-in backends, use 'django.db.backends.xxx', where xxx is one of:\n    'oracle', 'postgresql', 'sqlite3'<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u9519\u8bef\u5206\u6790<\/strong><\/p>\n<p>\u6b64\u9519\u8bef\u8868\u660e django \u65e0\u6cd5\u627e\u5230\u6216\u5bfc\u5165  \u6570\u636e\u5e93\u540e\u7aef\u6a21\u5757\u3002\u5728  3.8 \u4e2d\uff0c\u5185\u7f6e\u7684 mysql \u540e\u7aef\u9a71\u52a8\u5df2\u5220\u9664\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848<\/strong><\/p>\n<p>\u8981\u89e3\u51b3\u6b64\u95ee\u9898\uff0c\u8bf7\u786e\u4fdd\u4ee5\u4e0b\u4e8b\u9879\uff1a<\/p>\n<ol>\n<li><strong>\u4f7f\u7528\u6b63\u786e\u7684 python \u7248\u672c<\/strong><\/li>\n<\/ol>\n<p>\u95ee\u9898\u4e2d\u63d0\u5230\u7684 django \u548c mysqlclient \u7248\u672c\u9002\u7528\u4e8e python 3.7\u3002\u8bf7\u68c0\u67e5\u4f60\u7684 python \u7248\u672c\u662f\u5426\u6b63\u786e\u3002<\/p>\n<ol>\n<li><strong>\u5b89\u88c5 mysql \u9a71\u52a8<\/strong><\/li>\n<\/ol>\n<p>\u5bf9\u4e8e python 3.8 \u53ca\u66f4\u9ad8\u7248\u672c\uff0c\u9700\u8981\u5b89\u88c5 mysql \u9a71\u52a8\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>pip install mysql-connector-python<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ol>\n<li><strong>\u4fee\u6539\u6570\u636e\u5e93\u914d\u7f6e<\/strong><\/li>\n<\/ol>\n<p>\u5728 settings.py \u4e2d\uff0c\u5c06\u6570\u636e\u5e93\u540e\u7aef\u66f4\u65b0\u4e3a &#8220;django.db.backends.mysql&#8221;:<\/p>\n<pre>databases = {\n    'default': {\n        'engine': 'django.db.backends.mysql',\n        # \u5176\u4ed6\u6570\u636e\u5e93\u914d\u7f6e...\n    }\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ol>\n<li><strong>\u91cd\u542f django \u670d\u52a1<\/strong><\/li>\n<\/ol>\n<p>\u5b89\u88c5 mysql \u9a71\u52a8\u540e\uff0c\u52a1\u5fc5\u91cd\u542f django \u670d\u52a1\u4ee5\u52a0\u8f7d\u65b0\u9a71\u52a8\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>python manage.py runserver<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u63d0\u793a\uff1a<\/strong><\/p>\n<p>\u5982\u679c\u5728\u5b89\u88c5 mysql-connector-python \u65f6\u9047\u5230\u95ee\u9898\uff0c\u8bf7\u786e\u4fdd\u5df2\u5b89\u88c5\u4ee5\u4e0b\u4f9d\u8d56\u9879\uff1a<\/p>\n<ul>\n<li>visual c++ tributable<\/li>\n<li>mysql \u5f00\u53d1\u5e93 (\u7528\u4e8e \/)<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662fDjango \u9879\u76ee\u8fd0\u884c\u65f6\u62a5\u9519\u201cdjango.core.exceptions.ImproperlyConfigured: &#8216;django.db.backends.&#8217; isn&#8217;t an avlable database backend\u201d\uff0c\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>\u8fd0\u884c django \u9879\u76ee\u65f6\u201cdjango.ore.exceptions.improperlyconfigured\u201d\u9519\u8bef \u9879\u76ee\u5728\u8fd0\u884c\u65f6\u51fa\u73b0\u4e86\u5982\u4e0b\u9519\u8bef\uff1a django.core.exceptions.improperlyconfigured: &#8216;django.db.backends.mysql&#8217; isn&#8217;t an available database backend or couldn&#8217;t be imported. check the above exception. to use one of the built-in backends, use &#8216;django.db.backends.xxx&#8217;, where xxx is one of: &#8216;oracle&#8217;, &#8216;postgresql&#8217;, &#8216;sqlite3&#8217; \u767b\u5f55\u540e\u590d\u5236 \u9519\u8bef\u5206\u6790 \u6b64\u9519\u8bef\u8868\u660e django \u65e0\u6cd5\u627e\u5230\u6216\u5bfc\u5165 \u6570\u636e\u5e93\u540e\u7aef\u6a21\u5757\u3002\u5728 3.8 \u4e2d\uff0c\u5185\u7f6e\u7684 mysql \u540e\u7aef\u9a71\u52a8\u5df2\u5220\u9664\u3002 \u89e3\u51b3\u65b9\u6848 \u8981\u89e3\u51b3\u6b64\u95ee\u9898\uff0c\u8bf7\u786e\u4fdd\u4ee5\u4e0b\u4e8b\u9879\uff1a \u4f7f\u7528\u6b63\u786e\u7684 python \u7248\u672c \u95ee\u9898\u4e2d\u63d0\u5230\u7684 django \u548c mysqlclient [&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-7616","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7616","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=7616"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7616\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=7616"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=7616"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=7616"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}