1、
In Django project settings.py file, configure database connection information:
DATABASES = {
"default": {
"ENGINE": "django.db.backends.mysql",
"NAME": "Your database name", # need to manually create the database
"uSER": "database username",
"pASSWORD": "database password",
"HOST": "database IP",
"POST": 3306
}
}
2,
Write the following code in __init__.py file in the directory with the same name in Django project, told Django uses pymysql modules connect to the MySQL database:
Import pymysql
pymysql.install_as_MySQLdb ()