Authentication plugin #39;caching_sha2_password#39; is not supported(不支持身份验证插件“caching_sha2_password)
问题描述
我正在尝试使用 python 连接器连接到 MySQL 服务器.我使用身份验证插件 mysql_native_password
创建了一个新用户 lcherukuri
.
I am trying to connect to a MySQL server with python connector. I created a new user lcherukuri
with the authentication plugin mysql_native_password
.
但是我得到了错误
mysql.connector.errors.NotSupportedError: 不支持认证插件'caching_sha2_password'
mysql.connector.errors.NotSupportedError: Authentication plugin 'caching_sha2_password' is not supported
有人可以帮我吗?
import mysql.connector
cnx = mysql.connector.connect(user='lcherukuri', password='password',
host='127.0.0.1',
database='test')
cnx.close()
推荐答案
Per 缓存 SHA-2 可插入身份验证
在 MySQL 8.0 中,caching_sha2_password
是默认的身份验证插件,而不是 mysql_native_password
.
In MySQL 8.0,
caching_sha2_password
is the default authentication plugin rather thanmysql_native_password
.
您正在使用 mysql_native_password
,这不再是默认设置.假设您使用的是适用于您的版本的正确连接器,您需要指定 实例化时的auth_plugin
参数你的连接对象
You're using mysql_native_password
, which is no longer the default. Assuming you're using the correct connector for your version you need to specify the auth_plugin
argument when instantiating your connection object
cnx = mysql.connector.connect(user='lcherukuri', password='password',
host='127.0.0.1', database='test',
auth_plugin='mysql_native_password')
来自那些相同的文档:
connect()
方法支持可用于强制使用特定插件的 auth_plugin
参数.例如,如果服务器默认配置为使用 sha256_password
并且您想要连接到使用 mysql_native_password
进行身份验证的帐户,请使用 SSL 连接或指定 auth_plugin='mysql_native_password'
.
The
connect()
method supports anauth_plugin
argument that can be used to force use of a particular plugin. For example, if the server is configured to usesha256_password
by default and you want to connect to an account that authenticates usingmysql_native_password
, either connect using SSL or specifyauth_plugin='mysql_native_password'
.
这篇关于不支持身份验证插件“caching_sha2_password"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:不支持身份验证插件“caching_sha2_password"


基础教程推荐
- CHECKSUM 和 CHECKSUM_AGG:算法是什么? 2021-01-01
- ORA-01830:日期格式图片在转换整个输入字符串之前结束/选择日期查询的总和 2021-01-01
- 带更新的 sqlite CTE 2022-01-01
- 带有WHERE子句的LAG()函数 2022-01-01
- 使用 VBS 和注册表来确定安装了哪个版本和 32 位 2021-01-01
- 如何在 CakePHP 3 中实现 INSERT ON DUPLICATE KEY UPDATE aka upsert? 2021-01-01
- MySQL根据从其他列分组的值,对两列之间的值进行求和 2022-01-01
- MySQL 5.7参照时间戳生成日期列 2022-01-01
- 从字符串 TSQL 中获取数字 2021-01-01
- while 在触发器内循环以遍历 sql 中表的所有列 2022-01-01