Solution 1
Using the Pymysql module, you can use PIP install Pymysql directly.
Reference article: https://www.cnblogs.com/wcwnina/p/8719482.html
Original content:
Python3 does not support MYSQLDB and can be replaced with Pymysql. CMD installation pymysql:pip install Pymysql. Add the following code to the _init_.py under the project folder. Import pymysqlpymysql.install_as_mysqldb () and then perform the database Migration command in terminal: Python manage.py Makemigrationspython manage.py Migrate
Solution 2
This article strongly recommends the use of the implementation of the method. Because of the Pymysql module in Method 1, there may be some bugs that are difficult to solve due to module problems in the project's subsequent operation of the MySQL database.
It is recommended to use the Mysqlclient module here. Note that Python3 is not able to install mysqlclient directly using PIP install Mysqlclient, but Python2 can do so. So Python3 how to properly install the Mysqlclient module? You need to install two front-facing packages here, as follows:
(1) sudo apt-get install Python-dev Libmysqlclient-dev # Debian/ubuntu
(2) sudo apt-get install Python3-dev # Debian/ubuntu
The above two-step installation statement is installed on the Ubuntu system, windows or CentOS system, and the command is matched against the replacement.
After installing the two Libmysqlclient-dev, python3-dev front package, and then using the PIP install Mysqlclient can be successfully installed on the Python3.
Original link: Https://github.com/PyMySQL/mysqlclient-python
Driver module installation solution based on Python3.6 using Django framework to connect MySQL database