解决django 使用 mysql-client 问题 2026 ‘SSL connection error : unknow error number’

报错图片为

原因是 python2下是使用的MySQLdb,python3下用的是pymysql 

所以 pip install pymysql 并进行配置

配置方式:

第一步:pip install pymysql

第二步:

  将pymysql引入到django

  在和项目目录一样名字的包下面的__init__.py文件中写入以下代码:

       import pymysql

  pymysql.install_as_MySQLdb()

运行时发现如下截图报错

 打开报错的base.py 文件,将报错的两句注释掉

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

再次启动时报错  AttributeError: 'str' object has no attribute 'decode'

   找到报错的 operations.py 文件,将报错部分的decode修改成encode

猜你喜欢

转载自www.cnblogs.com/maxy11/p/12762687.html