在Python2.7中遇到MySQLDB SSL连接错误
我必须维护一个使用Python2.7构建的旧网站,该网站需要继续工作,直到我们用更现代的工具创建了一个全新的版本。现在,这个旧网站需要访问远程MySQL数据库(建立并正常工作),到目前为止,该数据库已使用以下内容进行了工作:
import MySQLdb
db = MySQLdb.connect(host=Host,user=User,passwd=Pass,db=DBse)
现在,服务器已从Ubuntu 18.04升级。到ubuntu 20.04。,当我设法安装pip
和mysqldb
for python2.7时,我现在在上述行中获得以下错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/MySQLdb/__init__.py", line 86, in Connect
return Connection(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 204, in __init__
super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (2026, 'SSL connection error: unknown error number')
SSL连接在python3或直接从命令行。
我有什么可以做这项工作的吗?
I have to maintain an old website built using Python2.7 that needs to continue working until we've finished creating a completely new version with more modern tools. Now this old website needs access to a remote MySQL database (connection is set up and working correctly), which so far has worked using the following:
import MySQLdb
db = MySQLdb.connect(host=Host,user=User,passwd=Pass,db=DBse)
Now the server has been upgraded from Ubuntu 18.04. to Ubuntu 20.04., and while I managed to install pip
and MySQLdb
for Python2.7, I now get the following error for the lines above:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/MySQLdb/__init__.py", line 86, in Connect
return Connection(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 204, in __init__
super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (2026, 'SSL connection error: unknown error number')
The SSL connection works fine in Python3 or directly from the command line.
Is there anything I can do to make this work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在/etc/mysql/my.cnf中找到并添加行Skip_ssl(在MySQL 8.0.29,Ubuntu 18中尝试过)
这是对我唯一有用的东西。
[mysqld]
skip_ssl
Locate and add the line skip_ssl in /etc/mysql/my.cnf ( have tried this on MySQL 8.0.29 , Ubuntu 18)
This was the only thing that worked for me.
[mysqld]
skip_ssl