Django开发,由sqlite3切换为mysql
已经伪装过了, 迁移时,报错:
django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.
解决办法:
将Django降低到2.14以下即可。(没试过)
II、升级mysql客户端版本至更高。(没试过)
III、按照以下步骤修改代码。 (亲测有效)
按图找到你Django目录下的base.py文件
注释掉下面2句:
if version < (1, 3, 13):
raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.version)
然后再进行数据库迁移操作。
如果还有问题,比如出现了以下问题:
File "D:\Program Files\Python37\lib\site-packages\django\db\backends\mysql\operations.py", line 146, in last_executed_query
query = query.decode(errors='replace')
AttributeError: 'str' object has no attribute 'decode'
那就打开上图中的operations.py文件,146行中的decode改为encode即可。
然后再次迁移,成功!