2019-12-10

搭建Django2.0+Python3+MySQL5时同步数据库时报错:

django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.3 or newer is required; you have 0.7.11.None

解决办法:

找到Python安装路劲下的Python36-32\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__)

重新在项目manage.py路劲下执行如下命令即可

python manage.py makemigrations

python manage.py migrate

附:Django配置MySQL数据库方法

一、settings.py文件中修改数据库配置为下面的内容:

# Database

# https://docs.djangoproject.com/en/2.0/ref/settings/#databases

DATABASES = {

'default': {

'ENGINE': 'django.db.backends.mysql',

'HOST': '127.0.0.1',

'PORT': '3306',

'NAME': 'mysql',

'USER': 'root',

'PASSWORD': 'zwg123456',

'OPTIONS': {

'init_command': "SET sql_mode='STRICT_TRANS_TABLES'",

},

}

}

你可能感兴趣的:(2019-12-10)