+-
python – 不支持身份验证插件“caching_sha2_password”
我试图用 python连接器连接到 MySQL服务器.我用身份验证插件mysql_native_password创建了一个新的用户lcherukuri.

但我得到了错误

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()

enter image description here

最佳答案
每 Caching SHA-2 Pluggable Authentication

In MySQL 8.0, caching_sha2_password is the default authentication plugin rather than mysql_native_password.

您使用的是mysql_native_password,它不再是默认值.假设您正在使用correct connector for your version,则需要在实例化连接对象时指定the auth_plugin argument

cnx = mysql.connector.connect(user='lcherukuri', password='password',
                              host='127.0.0.1', database='test',
                              auth_plugin='mysql_native_password')

从那些相同的文档:

The connect() method supports an auth_plugin argument that can be used to force use of a particular plugin. For example, if the server is configured to use sha256_password by default and you want to connect to an account that authenticates using mysql_native_password, either connect using SSL or specify auth_plugin='mysql_native_password'.

点击查看更多相关文章

转载注明原文:python – 不支持身份验证插件“caching_sha2_password” - 乐贴网