[1187]win环境2026, SSL connection error: unknown error number

先贴上详细的报错信息

代码语言:javascript
复制
PS D:\test\orchard_liang>python manage.py sqlmigrate app 0001
Traceback (most recent call last):
  File "D:\Python37\lib\site-packages\django\db\backends\base\base.py", line 219, in ensure_connection
    self.connect()
  File "D:\Python37\lib\site-packages\django\utils\asyncio.py", line 33, in inner
    return func(*args, **kwargs)
  File "D:\Python37\lib\site-packages\django\db\backends\base\base.py", line 200, in connect
    self.connection = self.get_new_connection(conn_params)
  File "D:\Python37\lib\site-packages\django\utils\asyncio.py", line 33, in inner
    return func(*args, **kwargs)
  File "D:\Python37\lib\site-packages\django\db\backends\mysql\base.py", line 234, in get_new_connection
    connection = Database.connect(**conn_params)
  File "D:\Python37\lib\site-packages\MySQLdb\__init__.py", line 84, in Connect
    return Connection(*args, **kwargs)
  File "D:\Python37\lib\site-packages\MySQLdb\connections.py", line 179, in __init__
    super(Connection, self).__init__(*args, **kwargs2)
MySQLdb._exceptions.OperationalError: (2026, 'SSL connection error: unknown error number')

原因:较高版本的mysql的ssl默认是开启的 解决方案:关闭ssl

第一步:先查看ssl开启情况

代码语言:javascript
复制
登录mysql之后,输入该命令:
mysql> SHOW VARIABLES LIKE '%ssl%';
image.png

第二步:修改配置文件my.ini

代码语言:javascript
复制
[mysqld]
skip_ssl  # 忽略ssl

第三步:重启mysql服务

ctrl+shift+esc按键调出任务管理器—>服务—>找到mysql服务—>右键重新运行

image.png

第四步:重新执行命令:

代码语言:javascript
复制
mysql> SHOW VARIABLES LIKE '%ssl%';
image.png

参考:https://blog.csdn.net/weixin_44065501/article/details/124018738 https://blog.csdn.net/qq_41538097/article/details/118909849