首页 > 解决方案 > 为什么在建立 mysql 到 python 连接时出现错误?

问题描述

当我在 Python 中连接 db 时出现错误:

mysql.connector.errors.NotSupportedError:不支持身份验证插件“caching_sha2_password”

代码:

import mysql.connector
mydb = mysql.connector.connect(
  host="localhost",
  user="root",
  passwd="prakash17"
)
print(mydb)

标签: pythonmysql

解决方案


此处已对此进行了回答: 不支持身份验证插件'caching_sha2_password'

解决方案是安装 mysql-connector-python 而不是 mysql-connector:

pip install mysql-connector-python

推荐阅读