django 连接mysql报错

1.django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.

修改/usr/local/lib/python3.5/dist-packages/django/db/backends/mysql/base.py文件,注释掉:

#if version < (1, 3, 13):           #raise ImproperlyConfigured(mysqlclient 1.3.13 or newer is required; you have %s. % Database.__version__)

2.django.db.utils.OperationalError: (2003, “Can‘t connect to MySQL server on ‘127.0.0.1‘ (111)”

检查服务器是否能连接到数据库,是否有什么限制,eg:端口等等

3.AttributeError: ‘str‘ object has no attribute ‘decode‘

cd /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/Django-2.2-py3.7.egg/django/db/backends/mysqlvim operations.py找到错误代码(line146):query = query.encode(errors=replace)解决方法:把decode改为encode即可。保存并退出。

 

相关文章