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.