本文介绍了“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 需要加密"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!