mysql.connector 操作 MySQL的问题 (1)

当Mysql的版本为8.0及以上时

如果利用mysql.connector连接Mysql出现如下错误:

mydb = mysql.connector.connect(host="localhost", user="root", passwd="1234", database="rac_ecust")

mysql.connector.errors.NotSupportedError: Authentication plugin 'caching_sha2_password' is not supported

可以采用如下方式解决:

mydb = mysql.connector.connect(host="localhost", user="root", passwd="1234", database="rac_ecust", auth_plugin='mysql_native_password')

猜你喜欢

转载自blog.csdn.net/sinat_32330093/article/details/88605846