[英]Connect Python to MySQL DB
由于身份验证插件,无法将我的代码连接到我的MySQL数据库
我正在尝试将我的代码连接到新安装的MySQL数据库。 我知道在MySQL 8.X及以上版本中,默认情况下认证类型设置为sha2,我读过我需要“强制”使用不同的认证插件(auth_plugin ='mysql_native_password')。
嗯...我做到了但我仍然收到相同的错误消息:
“不支持身份验证插件”{0}“”。format(plugin_name))mysql.connector.errors.NotSupportedError:不支持身份验证插件“caching_sha2_password”
我还该怎么办?
谢谢
import mysql.connector as Sql
myDB = Sql.connect(
host="localhost",
user="dbadmin",
password="myPassword",
auth_plugin="mysql_native_password"
)
print(myDB)
这确实解决了我的问题:
I had the same problem and passing auth_plugin='mysql_native_password' did not work,
because I accidentally installed mysql-connector instead of mysql-connector-python (via
pip3). Just to leaving this here in case it helps someone.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.