python 无法连接 mysql数据库 mysql Authentication plugin ‘caching_sha2_password‘ is not supported

python 无法连接 mysql数据库 mysql Authentication plugin ‘caching_sha2_password‘ is not supported

环境 :
python3.9.1 mysql8.0.22

问题:
import mysql.connector
cdb=mysql.connector.connect(
host=“localhost”,
user=“root”,
passwd=“××××××”
)
ccursor=cdb.cursor()
ccursor.execute(“drop database if exists studyDB”)
ccursor.execute(“create database studyDB”)
ccursor.execute(“use studyDB”)
ccursor.execute(“create table shopT(name varchar(100),price int(12))”)
ccursor.execute(“insert into shopT(name,price) values(‘苹果’,3)”)
cdb.commit()

报错:
mysql.connector.errors.NotSupportedError: Authentication plugin ‘caching_sha2_password’ is not supported

解决方法:
cdb=mysql.connector.connect(
host=“localhost”,
user=“root”,
passwd=“××××××”,

你可能感兴趣的:(数据库,mysql,python)