Repeated NotSupportedError: Authentication plugin 'caching_sha2_password' is not supported tried the previous solutions to no avail

Repeated NotSupportedError: Authentication plugin 'caching_sha2_password' is not supported tried the previous solutions to no avail

当我尝试通过 jupyter notebooks 连接到数据库时,我不断收到错误消息。 我尝试了所有解决方案,例如: 重新安装 mysql-connector-python(没用) 通过参数 auth_plugin='mysql_native_password' 确保 mysql 是最新的并且匹配我的 python 版本 (3.9) 我已经尝试了所有方法,但仍然出现错误。

这是我的代码:

mydb = mysql.connector.connect(
    host = 'localhost',
    user = 'root',
    passwd = 'oxxmcN4Fer7@HQie',
    database = 'testdb',
    auth_plugin='mysql_native_password'
)

尝试

pip uninstall mysql-connector-python

pip install mysql-connector-python  

在windows命令行中window。

如果失败,请尝试

reconfigure MySql 服务器

来自 MySql installer

然后选择Use Legacy Authentication Method (Retain MySql 5x Compatibility)Authentication Method

Reconfiguring MySql serverreinstalling mysql connector python 消除了我的错误