{"id":200630,"date":"2025-05-06T11:42:26","date_gmt":"2025-05-06T03:42:26","guid":{"rendered":"https:\/\/server.hk\/cnblog\/200630\/"},"modified":"2025-05-06T11:42:26","modified_gmt":"2025-05-06T03:42:26","slug":"pycharm-%e4%b8%ad%e4%bd%bf%e7%94%a8-django-%e6%97%a0%e6%b3%95%e5%88%9b%e5%bb%ba-mysql-%e6%95%b0%e6%8d%ae%e8%a1%a8%ef%bc%9a%e4%b8%ba%e4%bb%80%e4%b9%88%e6%88%91%e7%9a%84%e6%95%b0%e6%8d%ae%e8%a1%a8","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/200630\/","title":{"rendered":"PyCharm \u4e2d\u4f7f\u7528 Django \u65e0\u6cd5\u521b\u5efa MySQL \u6570\u636e\u8868\uff1a\u4e3a\u4ec0\u4e48\u6211\u7684\u6570\u636e\u8868\u6ca1\u6709\u751f\u6210\uff1f"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>PyCharm \u4e2d\u4f7f\u7528 Django \u65e0\u6cd5\u521b\u5efa MySQL \u6570\u636e\u8868\uff1a\u4e3a\u4ec0\u4e48\u6211\u7684\u6570\u636e\u8868\u6ca1\u6709\u751f\u6210\uff1f<\/h1>\n<p>\u77e5\u8bc6\u70b9\u638c\u63e1\u4e86\uff0c\u8fd8\u9700\u8981\u4e0d\u65ad\u7ec3\u4e60\u624d\u80fd\u719f\u7ec3\u8fd0\u7528\u3002\u4e0b\u9762\u4e3b\u673a\u5b9d\u8d1d\u7ed9\u5927\u5bb6\u5e26\u6765\u4e00\u4e2a\u6570\u636e\u5e93\u5f00\u53d1\u5b9e\u6218\uff0c\u624b\u628a\u624b\u6559\u5927\u5bb6\u5b66\u4e60\u300aPyCharm \u4e2d\u4f7f\u7528 Django \u65e0\u6cd5\u521b\u5efa MySQL \u6570\u636e\u8868\uff1a\u4e3a\u4ec0\u4e48\u6211\u7684\u6570\u636e\u8868\u6ca1\u6709\u751f\u6210\uff1f\u300b\uff0c\u5728\u5b9e\u73b0\u529f\u80fd\u7684\u8fc7\u7a0b\u4e2d\u4e5f\u5e26\u5927\u5bb6\u91cd\u65b0\u6e29\u4e60\u76f8\u5173\u77e5\u8bc6\u70b9\uff0c\u6e29\u6545\u800c\u77e5\u65b0\uff0c\u56de\u5934\u770b\u770b\u8bf4\u4e0d\u5b9a\u53c8\u6709\u4e0d\u4e00\u6837\u7684\u611f\u609f\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241110\/173121485267303e0457cdd.jpg\" class=\"aligncenter\"><\/p>\n<p><strong>\u5728 pycharm \u4e2d\u4f7f\u7528 django \u65e0\u6cd5\u6210\u529f\u521b\u5efa mysql \u6570\u636e\u8868<\/strong><\/p>\n<p>\u5728 pycharm \u4e2d\u4f7f\u7528 django \u8fde\u63a5 mysql \u6570\u636e\u5e93\u540e\uff0c\u5728\u6267\u884c\u201cpython3 manage.py makemigrations\u201d\u547d\u4ee4\u540e\u5374\u53d1\u73b0 mysql \u6570\u636e\u8868\u6ca1\u6709\u521b\u5efa\u6210\u529f\u3002<\/p>\n<p><strong>\u7cfb\u7edf\u73af\u5883\uff1a<\/strong><\/p>\n<ul>\n<li>windows 10<\/li>\n<li>python 3.8.6<\/li>\n<li>django 3.2.19<\/li>\n<li>mysqlclient 2.1.1<\/li>\n<li>mysql 0.0.3<\/li>\n<\/ul>\n<p><strong>\u9879\u76ee\u914d\u7f6e\uff1a<\/strong><\/p>\n<ul>\n<li>models.py \u4e2d\u5b9a\u4e49\u4e86\u6a21\u578b<\/li>\n<li>settings.py \u4e2d\u6ce8\u518c\u4e86 app \u5e76\u914d\u7f6e\u6570\u636e\u5e93\u4fe1\u606f<\/li>\n<\/ul>\n<p><strong>\u95ee\u9898\u73b0\u8c61\uff1a<\/strong><\/p>\n<ul>\n<li>\u8fd0\u884c\u201cpython3 manage.py makemigrations\u201d\u548c\u201cpython3 manage.py migrate\u201d\u547d\u4ee4\u540e\uff0cmysql \u4e2d\u6ca1\u6709\u521b\u5efa\u6570\u636e\u8868\u3002<\/li>\n<\/ul>\n<p><strong>\u89e3\u51b3\u65b9\u6cd5\uff1a<\/strong><\/p>\n<p>\u7ecf\u8fc7\u4ed4\u7ec6\u68c0\u67e5\uff0c\u53d1\u73b0\u8be5\u95ee\u9898\u662f\u7531 python 3 \u7684\u7248\u672c\u51b2\u7a81\u5f15\u8d77\u7684\u3002\u5728 windows \u73af\u5883\u4e2d\uff0c\u4f7f\u7528\u201cpython3\u201d\u547d\u4ee4\u53ef\u80fd\u4f1a\u6267\u884c windows \u81ea\u5e26\u7684 python 3\uff0c\u800c\u4e0d\u662f\u5b89\u88c5\u7684 python 3.8.6\u3002\u56e0\u6b64\uff0c\u9700\u8981\u660e\u786e\u6307\u5b9a python \u89e3\u91ca\u5668\uff1a<\/p>\n<pre>python manage.py makemigrations\npython manage.py migrate<\/pre>\n<p><strong>\u63d0\u793a\uff1a<\/strong><\/p>\n<ul>\n<li>\u8fd0\u884c\u201cpython\u201d\u547d\u4ee4\uff0c\u5982\u679c\u6253\u5f00\u7684\u662f windows \u5e94\u7528\u5546\u5e97\uff0c\u5219\u8bf4\u660e\u5f53\u524d\u73af\u5883\u4f7f\u7528\u7684 python 3 \u662f windows \u81ea\u5e26\u7684\u3002<\/li>\n<li>\u6b63\u786e\u5b89\u88c5\u7684 python 3 \u5e94\u8be5\u53ef\u4ee5\u901a\u8fc7\u76f4\u63a5\u8fd0\u884c\u201cpython\u201d\u547d\u4ee4\u8fdb\u5165\u3002<\/li>\n<\/ul>\n<p>\u597d\u4e86\uff0c\u672c\u6587\u5230\u6b64\u7ed3\u675f\uff0c\u5e26\u5927\u5bb6\u4e86\u89e3\u4e86\u300aPyCharm \u4e2d\u4f7f\u7528 Django \u65e0\u6cd5\u521b\u5efa MySQL \u6570\u636e\u8868\uff1a\u4e3a\u4ec0\u4e48\u6211\u7684\u6570\u636e\u8868\u6ca1\u6709\u751f\u6210\uff1f\u300b\uff0c\u5e0c\u671b\u672c\u6587\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\uff01\u5173\u6ce8\u4e3b\u673a\u5b9d\u8d1d\u516c\u4f17\u53f7\uff0c\u7ed9\u5927\u5bb6\u5206\u4eab\u66f4\u591a\u6570\u636e\u5e93\u77e5\u8bc6\uff01<\/p>\n<dl>\n<dt>\n <\/dt>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>PyCharm \u4e2d\u4f7f\u7528 Djan&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-200630","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/200630","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=200630"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/200630\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=200630"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=200630"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=200630"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}