[英]Django Connect remote Mysql OperationalError 2026
I'm using Django + mysql for days.我使用 Django + mysql 好几天了。 And this morning I suddenly found that I cannot get connect with the remote mysql.今天早上我突然发现我无法连接到远程mysql。
% python manage.py makemigrations
it raise它提高
django.db.utils.OperationalError: (2026, 'SSL connection error: SSL_CTX_set_tmp_dh failed')
also when也当
python manage.py runserver
Here's my environment:这是我的环境:
macOS 10.15 + Django 2.2.6 + MySQL 5.7 (on a remote server, ubuntu 18.04) + python 3.6.8 (use conda env) macOS 10.15 + Django 2.2.6 + MySQL 5.7(在远程服务器上,ubuntu 18.04)+ python 3.6.8(使用 conda env)
I've looked for some solutions like:我已经寻找了一些解决方案,例如:
downgrade openssl降级openssl
Package openssl conflicts for: openssl=1.0.2r python=3.6.8 -> openssl[version='>=1.1.1a,<1.1.2a']包 openssl 冲突: openssl=1.0.2r python=3.6.8 -> openssl[version='>=1.1.1a,<1.1.2a']
add use_pure=True in my .conf file在我的 .conf 文件中添加 use_pure=True
nothing changed没有改变
nothing changed没有改变
# setting.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'OPTIONS': {
'read_default_file': mysqlPath,
'init_command': 'SET default_storage_engine=INNODB',
},
}
}
# my_remote.cnf (which define the 'mysqlPath' in setting.py)
[client]
database = mydatabase
user = myusername
password = mypassword
default-character-set = utf8
host = myremotehost
port = 3306
use_pure = True
skip-ssl
skip_ssl
skip-ssl = True
skip_ssl = True
It is because your server isn't set up for SSL (yet).这是因为您的服务器尚未设置 SSL(尚未)。 Thus, the error is caused on the server-side.因此,错误是在服务器端引起的。
As already mentioned and tried successfully, a solution is to either make the server SSL-ready or set skip_ssl
to true
while in development.正如已经提到并成功尝试的那样,解决方案是在开发过程skip_ssl
服务器 SSL 就绪或将skip_ssl
设置为true
。
https://dev.mysql.com/doc/refman/5.7/en/using-encrypted-connections.html https://dev.mysql.com/doc/refman/5.7/en/using-encrypted-connections.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.