python - 使用 mysqyl-python 连接器时出现 SSL 连接错误

标签 python mysql mysql-python

我已经设置了一个正在运行的 mysql 实例(并且可以通过命令行以 root 或其他用户身份成功登录),但是在尝试连接时使用:

from mysql import connector 
conn = connector.connect(user='root', password='...', host='127.0.0.1')

我得到错误:

2026 (HY000): SSL connection error: SSL_CTX_set_tmp_dh failed

我是 mysql 的新手,很抱歉,如果这是一个明显的问题,但我们将不胜感激。

如果有帮助,这是我从命令行运行 mysql 时的状态:

mysql  Ver 8.0.13 for Linux on x86_64 (MySQL Community Server - GPL)

Connection id:      32
Current database:   
Current user:       root@localhost
SSL:            Not in use
Current pager:      stdout
Using outfile:      ''
Using delimiter:    ;
Server version:     8.0.13 MySQL Community Server - GPL
Protocol version:   10
Connection:     Localhost via UNIX socket
Server characterset:    utf8mb4
Db     characterset:    utf8mb4
Client characterset:    utf8mb4
Conn.  characterset:    utf8mb4
UNIX socket:        /var/run/mysqld/mysqld.sock
Uptime:         1 hour 6 min 28 sec

最佳答案

您是否运行了 mysql_ssl_rsa_setup命令?根据文档:

This program creates the SSL certificate and key files and RSA key-pair files required to support secure connections using SSL and secure password exchange using RSA over unencrypted connections

关于python - 使用 mysqyl-python 连接器时出现 SSL 连接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54136943/

相关文章:

python - conda的构建字符串是什么意思?

python - 从 Python 到 Azure 的 REST API 调用问题

php - 制作 $row 数组

php - 允许用户在 PHP 中投票一次

python - 在 CentOS 上使用 Python 脚本连接 MySQL

python - 将日期时间与日期时间范围进行比较

python - 根据连续行的空条件合并任意数量的文本列

.net - 将日期/时间字符串值转换为 .NET DateTime

python - Django Rest Framework/Django 性能问题

python - 如何在Python中使用mysqldb从mysql db获取数据并将它们插入到wx.ComboBox中