Configure the connection mysql
# DATABASES = { # 'default': { # 'ENGINE': 'django.db.backends.sqlite3', # 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), # } # } DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', #更换成mysql 'HOST':'127.0.0.1', #ip 'PORT': 3306, # ports ' NAME ' : ' orm01 ' , # library name ' the USER ' : ' the root ' , # username ' PASSWORD ' : ' 123 ' , # password } }
2 init file in the project folder, write the following two
import pymysql pymysql.install_as_MySQLdb()
Perform database synchronization instruction 3
python manage.py makemigrations python manage.py migrate