数据库
首页 > 数据库> > python 2.7 链接 MySQL 8.0.12 (常见错误与解决方法)

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

尝试修改链接配置项 ->  'auth_plugin':'mysql_native_password'  

3. 原先正常工作的代码开始花式报错,这里不过多表述

cursor is not defined    cnx is used before assigned  

解决方法

查询官方网站,重新下载驱动。  
pip install mysql-connector-python==8.0.12

 

  附上官网的描述与版本对应关系:   Note

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.

 

 

 

Note

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.

 

Note

Connector/Python does not support the old MySQL Server authentication methods, which means that MySQL versions prior to 4.1 will not work.

标签:8.0,12,python,MySQL,Connector,Python,version,mysql
来源: https://www.cnblogs.com/atuotuo/p/16286954.html