{"id":26764,"date":"2024-11-24T10:43:17","date_gmt":"2024-11-24T02:43:17","guid":{"rendered":"https:\/\/fwq.ai\/blog\/26764\/"},"modified":"2024-11-24T10:43:17","modified_gmt":"2024-11-24T02:43:17","slug":"django%e6%8a%a5%e9%94%99django-core-exceptions-improperlyconfigured-django-db-backends-mysql-isnt-an-available-database-backend%e6%80%8e%e4%b9%88%e8%a7%a3%e5%86%b3%ef%bc%9f-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/26764\/","title":{"rendered":"Django\u62a5\u9519\u201cdjango.core.exceptions.ImproperlyConfigured: &#8216;django.db.backends.mysql&#8217; isn&#8217;t an available database backend\u201d\u600e\u4e48\u89e3\u51b3\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173106054378333.jpg\" class=\"aligncenter\" title=\"Django\u62a5\u9519\u201cdjango.core.exceptions.ImproperlyConfigured: &#8216;django.db.backends.mysql&#8217; isn&#8217;t an available database backend\u201d\u600e\u4e48\u89e3\u51b3\uff1f\u63d2\u56fe\" alt=\"Django\u62a5\u9519\u201cdjango.core.exceptions.ImproperlyConfigured: &#8216;django.db.backends.mysql&#8217; isn&#8217;t an available database backend\u201d\u600e\u4e48\u89e3\u51b3\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u89e3\u51b3\u201cdjango.core.exceptions.improperlyconfigured\u201d\u9519\u8bef<\/strong><\/p>\n<p>\u5728\u4f60\u7684\u4ee3\u7801\u4e2d\uff0c\u9047\u5230\u4e86 &#8220;django.core.exceptions.improperlyconfigured: &#8216;django.db.backends.&#8217; isn&#8217;t an avlable database backend&#8221; \u9519\u8bef\u3002\u8fd9\u8868\u660e django \u65e0\u6cd5\u5bfc\u5165 mysql \u540e\u7aef\u3002<\/p>\n<p><strong>\u539f\u56e0<\/strong><\/p>\n<p>\u95ee\u9898\u5728\u4e8e\u4f60\u7684\u4ee3\u7801\u5b9e\u9645\u8fd0\u884c\u5728  3.8 \u800c\u975e 3.7 \u4e0a\u3002python 3.8 \u4e2d\u4e0d\u518d\u5185\u7f6e mysql \u540e\u7aef\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848<\/strong><\/p>\n<p>\u8981\u89e3\u51b3\u6b64\u95ee\u9898\uff0c\u9700\u8981\u4f7f\u7528\u7b2c\u4e09\u65b9\u5305\u6765\u5b89\u88c5 mysql \u540e\u7aef\u3002\u5177\u4f53\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<ol>\n<li>\u4f7f\u7528 pip \u5b89\u88c5 mysqlclient\uff1a<\/li>\n<\/ol>\n<pre>pip install mysqlclient<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ol>\n<li>\u4fee\u6539 settings.py \u4e2d\u7684 databases \u8bbe\u7f6e\uff1a<\/li>\n<\/ol>\n<pre>DATABASES = {\n    'default': {\n        'ENGINE': 'django.db.backends.mysql',\n        ...\n    }\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ol>\n<li>\u786e\u4fdd\u4f7f\u7528\u6b63\u786e\u7684\u6570\u636e\u5e93\u51ed\u636e\u3002<\/li>\n<\/ol>\n<p>\u91cd\u65b0\u8fd0\u884c\u670d\u52a1\u5668\uff0c\u9519\u8bef\u5e94\u5f97\u5230\u89e3\u51b3\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fDjango\u62a5\u9519\u201cdjango.core.exceptions.ImproperlyConfigured: &#8216;django.db.backends.&#8217; isn&#8217;t an avlable database backend\u201d\u600e\u4e48\u89e3\u51b3\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>\u89e3\u51b3\u201cdjango.core.exceptions.improperlyconfigured\u201d\u9519\u8bef \u5728\u4f60\u7684\u4ee3\u7801\u4e2d\uff0c\u9047\u5230\u4e86 &#8220;django.core.exceptions.improperlyconfigured: &#8216;django.db.backends.&#8217; isn&#8217;t an avlable database backend&#8221; \u9519\u8bef\u3002\u8fd9\u8868\u660e django \u65e0\u6cd5\u5bfc\u5165 mysql \u540e\u7aef\u3002 \u539f\u56e0 \u95ee\u9898\u5728\u4e8e\u4f60\u7684\u4ee3\u7801\u5b9e\u9645\u8fd0\u884c\u5728 3.8 \u800c\u975e 3.7 \u4e0a\u3002python 3.8 \u4e2d\u4e0d\u518d\u5185\u7f6e mysql \u540e\u7aef\u3002 \u89e3\u51b3\u65b9\u6848 \u8981\u89e3\u51b3\u6b64\u95ee\u9898\uff0c\u9700\u8981\u4f7f\u7528\u7b2c\u4e09\u65b9\u5305\u6765\u5b89\u88c5 mysql \u540e\u7aef\u3002\u5177\u4f53\u6b65\u9aa4\u5982\u4e0b\uff1a \u4f7f\u7528 pip \u5b89\u88c5 mysqlclient\uff1a pip install mysqlclient \u767b\u5f55\u540e\u590d\u5236 \u4fee\u6539 settings.py \u4e2d\u7684 databases \u8bbe\u7f6e\uff1a DATABASES = { &#8216;default&#8217;: { &#8216;ENGINE&#8217;: &#8216;django.db.backends.mysql&#8217;, &#8230; } } \u767b\u5f55\u540e\u590d\u5236 \u786e\u4fdd\u4f7f\u7528\u6b63\u786e\u7684\u6570\u636e\u5e93\u51ed\u636e\u3002 \u91cd\u65b0\u8fd0\u884c\u670d\u52a1\u5668\uff0c\u9519\u8bef\u5e94\u5f97\u5230\u89e3\u51b3\u3002 \u4ee5\u4e0a\u5c31\u662fDjango\u62a5\u9519\u201cdjango.core.exceptions.ImproperlyConfigured: [&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-26764","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/26764","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=26764"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/26764\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=26764"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=26764"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=26764"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}