mysql.connector.errors.NotSupportedError: Authentication plugin 'caching_sha2_password' is not supported

今天将程序部署到服务器,遇到

mysql.connector.errors.NotSupportedError: Authentication plugin 'caching_sha2_password' is not supported

问题产生的原因:

  从MySQL 8.0开始,默认的用户认证插件从mysql_native_password变成了caching_sha2_password

查看现有的用户

mysql> select user, host, plugin from mysql.user;
+------------------+-----------+-----------------------+
| user | host | plugin |
+------------------+-----------+-----------------------+
| root | % | mysql_native_password |
| test1| % | caching_sha2_password |
| mysql.infoschema | localhost | caching_sha2_password |
| mysql.session | localhost | caching_sha2_password |
| mysql.sys | localhost | caching_sha2_password |
+------------------+-----------+-----------------------+

使用连接mysql的账号test1加密规则为 caching_sha2_password

修改加密规则

ALTER USER 'test1'@'%' IDENTIFIED WITH 'mysql_native_password' BY 'password';
FLUSH PRIVILEGES;

更新mysql-connector库

pip install --upgrade mysql-connector-python

 

 

 

 

 

  

posted @ 2024-05-13 23:25  慕尘  阅读(40)  评论(0编辑  收藏  举报