【已解决】django3.x版本连接MySQL报错mysqlclient 1.3.13 or newer is required

前言

这个东西找了很久始终报错

mysqlclient 1.3.13 or newer is required; you have 0.9.3.

这里有个解决方案,解决了这个问题,然而这个方法是否为饮鸠止渴还有待实践

环境

  1. django 3.0.x
  2. python 3.6
  3. mysql 8.0.x

配置

安装

pip install pymysql

init.py文件

import pymysql
pymysql.version_info = (1, 3, 13, "final", 0)
pymysql.install_as_MySQLdb()

setting.py

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': '',  # 使用的数据库的名字
        'USER': '',  # 连接mysql的用户名
        'PASSWORD': '',  # 用户对应的密码
        'HOST': '',  # 指定mysql数据库所在电脑ip
        'PORT': 3306,  # 指定端口      
    }
}

这样秒解决

你可能感兴趣的:(django3,mysql,pymysql)