解决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()

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

相关推荐
花好月圆春祺夏安8 分钟前
基于odoo17的设计模式详解---装饰模式
数据库·python·设计模式
叁沐1 小时前
MySQL 06 全局锁和表锁:给表加个字段怎么有这么多阻碍?
mysql
萧鼎2 小时前
深度探索 Py2neo:用 Python 玩转图数据库 Neo4j
数据库·python·neo4j
华子w9089258592 小时前
基于 Python Django 和 Spark 的电力能耗数据分析系统设计与实现7000字论文实现
python·spark·django
power 雀儿2 小时前
集群聊天服务器---MySQL数据库的建立
服务器·数据库·mysql
Rockson2 小时前
使用Ruby接入实时行情API教程
javascript·python
Tipriest_3 小时前
Python关键字梳理
python·关键字·keyword
Edingbrugh.南空4 小时前
Flink MySQL CDC 环境配置与验证
mysql·adb·flink
im_AMBER5 小时前
学习日志05 python
python·学习
大虫小呓5 小时前
Python 处理 Excel 数据 pandas 和 openpyxl 哪家强?
python·pandas