python 2.7 链接 MySQL 8.0.12 (常见错误与解决方法)
背景描述
大约在一年前,写程序链接自己的MySQL==8.0.11时,使用的驱动是 mysql-connector-python-rf == 2.1.3 没有任何问题。
近期需要链接客户的MySQL==8.0.12时,出现了各种各样的问题。
错误信息描述
1. Could not import mysql.connector
尝试卸载 mysql-connector-python-rf,安装新版本。
2. password with cached 2 is not supported
3. 原先正常工作的代码开始花式报错,这里不过多表述
解决方法
pip install mysql-connector-python==8.0.12
MySQL Connectors and other MySQL client tools and applications now synchronize the first digit of their version number with the (highest) MySQL server version they support. For example, MySQL Connector/Python 8.0.12 would be designed to support all features of MySQL server version 8 (or lower). This change makes it easy and intuitive to decide which client version to use for which server version.
Connector/Python 8.0.4 is the first release to use the new numbering. It is the successor to Connector/Python 2.2.3.

MySQL server and Python versions within parentheses are known to work with Connector/Python, but are not officially supported. Bugs might not get fixed for those versions.
Connector/Python does not support the old MySQL Server authentication methods, which means that MySQL versions prior to 4.1 will not work.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
2017-05-19 Docker4Windows -- 从外部(非本机host)访问 由docker container运行的程序