gpt4 book ai didi

python - 从 python 验证 sql 数据库时出错

转载 作者:行者123 更新时间:2023-11-29 09:38:32 24 4
gpt4 key购买 nike

我正在尝试运行此代码:

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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com