django2.0版本连接mysql报错
报错信息:
django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.3 or newer is required; you have 0.7.11.None
解决办法:
E:\python35\Lib\site-packages\django\db\backends\mysql\base.py
打开文件之后注释掉:
#if version < (1, 3, 3):
# raise ImproperlyConfigured("mysqlclient 1.3.3 or newer is required; you have %s" % Database.__version__)
大约在: 35-36行,
安装:
pymysql
项目根目录, __init__.py 文件添加
import pymysql
pymysql.install_as_MySQLdb()
settings.py 文件数据库配置
{
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'blog',
'USER': 'wuyongc',
'PASSWORD': 'Test2018',
'HOST': '47.104.174.231',
'PORT': '3306',
'OPTIONS': {
'init_command': "SET sql_mode='STRICT_TRANS_TABLES'",
},
}
}