【发布时间】:2018-10-18 23:44:48
【问题描述】:
我正在尝试让我的 python 程序将数据插入 MySQL,我按照指南进行操作,但是我不断收到以下错误。
“不支持身份验证插件‘{0}’”.format(plugin_name)) mysql.connector.errors.NotSupportedError:不支持身份验证插件'caching_sha2_password'"
我错过了 mysql 服务器中的设置还是 python 还不支持这个?
我想我可以只更改密码类型,但由于某种原因 mysql 不允许我更改所有具有缓存_sha2_password 的用户,当我创建新用户并选择 SHA256 密码时,我收到创建帐户的错误@% 密码哈希没有预期的格式。检查 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()
【问题讨论】:
-
已解决:
pip install mysql-connector-python
标签: python mysql mysql-workbench