quot;cryptography is required for sha256_password or caching_sha2_passwordquot;(“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 需要加密"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:“sha256_password 或caching_sha2_password 需要加密"
基础教程推荐
- 表 './mysql/proc' 被标记为崩溃,应该修复 2022-01-01
- 如何在 SQL 中将 Float 转换为 Varchar 2021-01-01
- 什么是 orradiag_<user>文件夹? 2022-01-01
- 如何根据该 XML 中的值更新 SQL 中的 XML 2021-01-01
- 在多列上分布任意行 2021-01-01
- mysql选择动态行值作为列名,另一列作为值 2021-01-01
- oracle区分大小写的原因? 2021-01-01
- MySQL 中的类型:BigInt(20) 与 Int(20) 2021-01-01
- 在 MySQL 中:如何将表名作为存储过程和/或函数参数传递? 2021-01-01
- 二进制文件到 SQL 数据库 Apache Camel 2021-01-01
