简体   繁体   English

Django 连接远程 Mysql OperationalError 2026

[英]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没有改变

  • add skip_ssl in my .conf file在我的 .conf 文件中添加 skip_ssl

    nothing changed没有改变

note笔记

  • On the server (which I deploy my site, ubuntu 18.04) my site run well using gunicorn + Nginx在服务器上(我部署我的站点,ubuntu 18.04)我的站点使用 gunicorn + Nginx 运行良好
  • All the things worked well until today.直到今天,一切都运转良好。
  • The site broke when I found this issue but work well when I restart it.当我发现这个问题时,该站点崩溃了,但当我重新启动它时运行良好。
  • I guess maybe some update on the server (automatically upgrade) to cause the problem, but haven't find it yet.我想可能是服务器上的一些更新(自动升级)导致了问题,但还没有找到。

some of my code我的一些代码

# 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.

相关问题 django.db.utils.OperationalError: (2026, &#39;SSL 连接错误:SSL_CTX_set_tmp_dh 失败&#39;) - django.db.utils.OperationalError: (2026, 'SSL connection error: SSL_CTX_set_tmp_dh failed') Django-OperationalError:无法连接到服务器 - Django - OperationalError: could not connect to server 连接 django 和 mysql 时出现操作错误 - OperationalError while connecting django and mysql 将Django连接到本地网络上的远程mysql服务器 - Connect Django to remote mysql server on a local network 在Windows 10上使用Django连接到远程MySQL - Connect to remote mysql with django on Windows 10 Mysql OperationalError 1044,连接到mysql数据库 - Mysql OperationalError 1044, connect to mysql database django.db.utils.OperationalError: (2003, “无法连接到&#39;127.0.0.1&#39; (111) 上的 MySQL 服务器” - django.db.utils.OperationalError: (2003, "Can't connect to MySQL server on '127.0.0.1' (111)" django.db.utils.OperationalError:(2002,“无法连接到'db'(115)上的 MySQL 服务器”) - django.db.utils.OperationalError: (2002, “Can't connect to MySQL server on 'db' (115)”) Python无法连接到MySQL数据库:OperationalError - Python can't connect to MySQL db: OperationalError Django AWS RDS MySQL 错误:(2026,&#39;SSL 连接错误:错误:00000001:lib(0):func(0):reason(1)&#39;) - Django AWS RDS MySQL Error: (2026, 'SSL connection error: error:00000001:lib(0):func(0):reason(1)')
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM