一、运行项目报错信息如下:

File "/home/pyvip/.virtualenvs/myblog/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 36, in <module> raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.__version__)django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.

packages/django/db/backends/mysql/base.py,用vim将其打开


在这里插入图片描述

35,36行需要注释掉,然后就不会因为版本而报错,在末行模式下输入wq保存退出


在这里插入图片描述

二、再次运行项目报如下错误

File "/home/pyvip/.virtualenvs/myblog/lib/python3.6/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'


在这里插入图片描述

此时再次运行项目,可以看到运行成功了!!!证明mysql数据库连接成功!


总结

以上所述是小编给大家介绍的django2.2版本连接mysql数据库的方法,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对网站的支持!
如果你觉得本文对你有帮助,欢迎转载,烦请注明出处,谢谢!

更多相关文章

  1. 'xlargeScreens' in package 'android'
  2. Android(安卓)版本兼容 — Android(安卓)6.0 和 7.0后获取Mac地
  3. Android系统配置数据库注释(settings.db)
  4. android“设置”里的版本号
  5. Android(安卓)version and Linux Kernel version
  6. opengrok setup on ubuntu for android source code browser
  7. Android——开发环境
  8. android通过ksoap2对webservice的解析
  9. Android如何获得系统版本

随机推荐

  1. Android学习笔记06:线性布局LinearLayout
  2. 【Android进阶学习】实现没有标题栏的窗
  3. android 和JS互调
  4. Android第一周
  5. 理解onMeasure
  6. Android 中文 API (29) —— CompoundButto
  7. android 6.0-高通视频通话拨打流程
  8. Android.Tools.Summary
  9. Android 设置EditText光标Curso颜色及粗
  10. Android B/S 关于系统兼容性相关问题