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
Triggers can cause other SQL code to run before o...
Introduction The Docker community has created man...
As shown below: select a1,a2,a1+a2 a,a1*a2 b,a1*1...
By default, MySQL can accept the insertion of 0 v...
sed is a character stream editor under Unix, that...
1. Meaning of partition table A partition table d...
Shorthand properties are used to assign values ...
Recently I used MySQL to export table data to an ...
Dynamic rem 1. First, let’s introduce the current...
The following script is used for scheduled backup...
Two cases: 1. With index 2. Without index Prerequ...
In development projects, we can monitor SQL with ...
In daily work, we may encounter a layout like thi...
Table of contents 1. The elephant that can’t fit ...
Operation effect: html <div class="tic-ta...