在Python2.7中遇到MySQLDB SSL连接错误

发布于 2025-02-04 03:39:44 字数 862 浏览 1 评论 0原文

我必须维护一个使用Python2.7构建的旧网站,该网站需要继续工作,直到我们用更现代的工具创建了一个全新的版本。现在,这个旧网站需要访问远程MySQL数据库(建立并正常工作),到目前为止,该数据库已使用以下内容进行了工作:

import MySQLdb

db = MySQLdb.connect(host=Host,user=User,passwd=Pass,db=DBse)

现在,服务器已从Ubuntu 18.04升级。到ubuntu 20.04。,当我设法安装pipmysqldb 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

玩世 2025-02-11 03:39:44

在/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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文