"sha256_password或caching_sha2_password需要加密" [英] "cryptography is required for sha256_password or caching_sha2_password"
本文介绍了"sha256_password或caching_sha2_password需要加密"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
美好的一天.希望你一切都好.有人可以帮我解决这个问题吗?
Good day. Hope your all are well. Can someone help me with fix this?
我是MySQL环境的新手.我正在尝试远程连接到MySQL数据库.我使用以下python代码,并收到此错误.
I'm new to the MySQL environment. I'm trying to connect to MySQL Database remotely. I used the following python code and got this error.
Print(e) = "cryptography is required for sha256_password or
caching_sha2_password"
也不知道如何解决该错误.
And have no idea how to solve the error.
import pymysql as db
HOST = "XXXXX.XXX.XX"
PORT = XXXX
USER = "my_username"
PASSWORD = "my_password"
DB = "db_name"
try:
connection = db.Connection(host=HOST, port=PORT,user=USER,
passwd=PASSWORD, db=DB)
dbhandler = connection.cursor()
dbhandler.execute("SELECT * from table_name")
result = dbhandler.fetchall()
for item in result:
print (DB)
except Exception as e:
print(e)
finally:
connection.close()
推荐答案
import mysql.connector
def connection():
conn = mysql.connector.connect(host = "XXXXX",
user = 'XXXXX',
password = 'XXXXX',
database = 'login_page',
auth_plugin='mysql_native_password')
c = conn.cursor()
return c , conn
下载mysql连接器而不是pymysql并尝试以这种方式连接.它对我有用,希望对你也有用.
Download mysql connector rather than pymysql and try connecting this way. It worked for me, hope it works for u too.
这篇关于"sha256_password或caching_sha2_password需要加密"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文