在Python中连接数据库时,出现错误:
mysql.connector.errors.NotSupportedError:不支持身份验证插件'caching_sha2_password'
代码:
import mysql.connector
mydb = mysql.connector.connect(
host="localhost",
user="root",
passwd="prakash17"
)
print(mydb)
答案 0 :(得分:1)
已在此处回答: Authentication plugin 'caching_sha2_password' is not supported
解决方案是安装mysql-connector-python而不是mysql-connector:
pip install mysql-connector-python
答案 1 :(得分:0)
我认为问题是您的密码拼写错误。 尝试这个 密码='prakash17'
如果这不起作用,请尝试 密码=''
还要确保您的Xampp是可运行的apache和mysql。祝你好运!