解决wrap_socket() got an unexpected keyword argument ‘ciphers‘

看报错本以为是一个简单的传参问题,没想到查到盘丝洞。

python 复制代码
# 报错信息
wrap_socket() got an unexpected keyword argument 'ciphers'
python 复制代码
# 报错代码段
@_exception_handler()
def connect(self):
    u"""连接MySQL数据库"""
    self.config_connect_args()
    if not self.get_conn():
        self.conn = mysql.connector.connect(**self.connect_config)  # 报错行
        self.set_sql_timeout()
        self.init_my_variables()
    return True

此问题在 这里 有说明,我对其总结如下:

python版本 mysql-connector-python版本 结果
2.6.6 2.1.3 正常
2.6.6 2.1.7 报错
2.6.6 8.0.5b1 报错

解决办法:

python 复制代码
# 1.查看当前服务器安装的mysql-connector-python版本号
python
Python 2.6.6
[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import mysql.connector
>>> mysql.connector.__version__
'8.0.5b1'
>>> exit()

# 2.查找mysql-connector-python的包名
rpm -qa | grep mysql
mysql-connector-python-8.0.5-0.1.dmr.el6.x86_64

# 3.卸载这个版本
rpm -e mysql-connector-python-8.0.5-0.1.dmr.el6.x86_64

# 4.安装2.1.3版本(注:如果有冲突,看是不是还有其他版本,都卸载掉)
rpm -ivh mysql-connector-python-2.1.3-1.el6.x86_64.rpm
Preparing...                ########################################### [100%]
   1:mysql-connector-python ########################################### [100%]

# 5.检测mysql-connector-python的版本是否正确
python
Python 2.6.6 (r266:84292, Nov 22 2013, 12:16:22) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import mysql.connector
>>> mysql.connector.__version__
'2.1.3'
>>> exit()

完工,再测试,就不会有如标题的报错了。

相关推荐
Python×CATIA工业智造2 小时前
Frida RPC高级应用:动态模拟执行Android so文件实战指南
开发语言·python·pycharm
onceco2 小时前
领域LLM九讲——第5讲 为什么选择OpenManus而不是QwenAgent(附LLM免费api邀请码)
人工智能·python·深度学习·语言模型·自然语言处理·自动化
feifeigo1233 小时前
升级到MySQL 8.4,MySQL启动报错:io_setup() failed with EAGAIN
数据库·mysql·adb
狐凄3 小时前
Python实例题:基于 Python 的简单聊天机器人
开发语言·python
悦悦子a啊4 小时前
Python之--基本知识
开发语言·前端·python
笑稀了的野生俊6 小时前
在服务器中下载 HuggingFace 模型:终极指南
linux·服务器·python·bash·gpu算力
Naiva6 小时前
【小技巧】Python+PyCharm IDE 配置解释器出错,环境配置不完整或不兼容。(小智AI、MCP、聚合数据、实时新闻查询、NBA赛事查询)
ide·python·pycharm
路来了6 小时前
Python小工具之PDF合并
开发语言·windows·python
蓝婷儿6 小时前
Python 机器学习核心入门与实战进阶 Day 3 - 决策树 & 随机森林模型实战
人工智能·python·机器学习
AntBlack7 小时前
拖了五个月 ,不当韭菜体验版算是正式发布了
前端·后端·python