我正在尝试运行此代码:
from flask_sqlalchemy import SQLAlchemy
import mysql.connector
import csv
import pandas as pd
mydb = mysql.connector.connect(
host="127.0.0.1",
user="root",
passwd="abc123",
database="db"
)
但我收到此错误:
Traceback (most recent call last):
File "C:\Users\user123\Desktop\SQLtest\setup.py", line 10, in <module>
passwd="abc123",
.
.
.
"Authentication plugin '{0}' is not supported".format(plugin_name))
mysql.connector.errors.NotSupportedError: Authentication plugin 'caching_sha2_password' is not supported
如有任何帮助,我们将不胜感激。
最佳答案
出现此错误是因为 MySQL 8 使用 caching_sha2_password作为默认身份验证插件而不是 mysql_native_password。
要解决此问题,请尝试将 auth_plugin='mysql_native_password'
添加到您的连接参数 - 以使您的连接使用 native 身份验证插件 - 如下所示:
mydb = mysql.connector.connect(
host="127.0.0.1",
user="root",
passwd="abc123",
database="db",
auth_plugin="mysql_native_password"
)
关于python - 从 python 验证 sql 数据库时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57120970/