MySQL8 – "caching_sha2_password需要 SSL"



我已在服务器上更改为Mysql8。我通过ssh连接到服务器。使用(例如(VScode数据库资源管理器,我可以在服务器上使用,但从带有MySQL连接器的Python3中,我不能。

在服务器端,"ssl_disabled=True"解决了问题,但在我的计算机上,我无法连接到服务器的数据库。

import mysql.connector
from mysql.connector import Error
def create_connection():
connection = None
try:
connection = mysql.connector.connect(
host='host',
port='port',
user='user',
passwd='passwd',
database='db',
ssl_disabled=True,
)
print("Connection to MySQL DB successful")
except Error as e:
print(f"Error in create_connection -->n '{e}'")
return connection
create_connection()

我试着运行这个并得到:

'caching_sha2_password requires SSL'

我解决了它!如果我使用端口3307而不是3306,它也可以在本地机器上工作!

最新更新