mysql不支持缓存sha2密码

ada*_*rth 4 python mysql mysql-workbench

我正在尝试让我的python程序将数据插入MySQL,我遵循指南,但我不断收到以下错误.

"不支持身份验证插件"{0}"".format(plugin_name))mysql.connector.errors.NotSupportedError:不支持身份验证插件"caching_sha2_password"

我错过了mysql服务器中的设置还是python不支持这个?

我想我可以改变密码类型,但是mysql不想让我因为某些原因而无法更改所有使用caching_sha2_password的用户,当我创建新用户并选择SHA256密码时,我会收到错误创建帐户@%the密码哈希没有预期的格式.检查PASSWORD()函数是否使用了正确的密码算法.

#!/user
# -*- coding: utf-8 -*-

from __future__ import print_function
import urllib.request
import numpy as np
import mysql.connector as mysql

from datetime import date, datetime, timedelta



cnx = mysql.connect(user='root', password='password', database='powergrid')

cursor = cnx.cursor()

tomorrow = datetime.now().date() + timedelta(days=1)

idfueltype= cursor.lastrowid

add_fueltype = ("INSERT INTO fueltype"
                "(idfueltype, fueltypecol, demand)"
               "VALUES(%s, %s, %s)")

fueltype_data = (idfueltype, 'coal', 10000)

cursor.execute(add_fueltype, fueltype_data)

cnx.commit()

cursor.close()
cnx.close()
Run Code Online (Sandbox Code Playgroud)

ada*_*rth 17

我设法解决了这个问题.最后我在Anaconda中使用了一个版本的python,它不会安装python连接器的8.0.11版本,我设法使用Windows PowerShell在我的vanilla python 3.6.5上安装8.0.11(在管理员权限中)和使用pip install MySQL-connector-python(我想我也必须从9到10更新点子.


Giu*_*cci 5

我有同样的问题

“不支持身份验证插件'{0}'”。format(plugin_name))mysql.connector.errors.NotSupportedError:不支持身份验证插件'caching_sha2_password'。

发生这种情况是因为您的Python 连接器不支持身份验证插件,caching_sha2_password而您需要对其进行更新。我通过从MySQL官方站点安装正确的Python连接器来修复它。确保根据您的操作系统,MySQL版本和使用的Python版本下载正确的连接器。


DKM*_*gin 5

为python3安装驱动器。

python3 -m pip install mysql-connector-python

为制造商预安装在系统上的默认python安装驱动器。

python -m pip install mysql-connector-python
Run Code Online (Sandbox Code Playgroud)