Step 1: Change DATABASES in setting.py # Configure database DATABASES = { 'default': { # A database that comes with python, which is basically not used# 'ENGINE': 'django.db.backends.sqlite3', # 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), # Register our own database connection 'ENGINE': 'django.db.backends.mysql', # Database engine 'NAME': 'productone', # Database name 'USER':'root', # User name for connecting to the database 'PASSWORD':'yourpassword', # User password 'HOST':'127.0.0.1', # The IP address of the host of the database to be accessed 'PORT':'3306', # Default mysql access port } } The second step is to enter in the console: pip install pymysql to install pymysql Step 3: Add the following code to __init__.py in the project Because I had the following problem↓, I added pymysql.version_info = (1,4,13,"final",0) import pymysql pymysql.version_info = (1,4,13,"final",0) pymysql.install_as_MySQLdb() Finally, you can execute the program python manage.py migrate!!! Completed Summarize This is the end of this article about connecting Django to a local MySQL database (pycharm). For more information about connecting Django to a local MySQL database (pycharm), please search previous articles on 123WORDPRESS.COM or continue browsing the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Idea configures tomcat to start a web project graphic tutorial
>>: Vue+Element UI realizes the encapsulation of drop-down menu
Table of contents Preface What does yarn create d...
Operating environment: MAC Docker version: Docker...
<body> <div id="root"> <...
This article shares the specific code of JS to ac...
In fact, the three tables above all have three ro...
Table of contents Preface Mysql case when syntax:...
1. Use version vite:2.0 ant-design-vue: 2.0.0-rc....
During the development activity, I encountered a ...
One environment Alibaba Cloud Server: CentOS 7.4 ...
Table of contents Preface first step: Step 2: Mod...
The first type: full CSS control, layer floating ...
The code looks like this: <!DOCTYPE html> &...
Preface It is very simple to create a server in n...
Table of contents 1- Error details 2-Single Solut...
Configure Git environment in Docker At work, I en...