Report this

What is the reason for this report?

How to connect Django app to digital ocean managed database (MySQL) ?

Posted on December 19, 2019

Hi, I am kind of a beginner so I can be doing something very wrong, but this is my situation: I was trying to connect my Django application to my Digital ocean’s MySQL database, with the following configurations:

DATABASES = {

    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': '<name>',
        'USER': 'doadmin',
        'PASSWORD': '<pass>',
        'HOST': '<host>',
        'PORT': '25060',
        'OPTIONS': {
            'ssl': {
                'ca': <ca_certificate_downloaded_from_managing_page>,
                'cert': None,
                'key': None,
            },
        },
    }
}

These specifications were copied from the digital ocean cluster managing webpage, so no typos. I’ve downloaded the CA certificate and provided everything that was asked. With DBeaver everything seems to work fine. I’ve also tried to update mysql client but nothing works. This is the error that pops on the console:

(...)
  File "C:\Users\Alexandre\AppData\Local\Programs\Python\Python38-32\lib\site-packages\MySQLdb\connections.py", line 179, in __init__
    super(Connection, self).__init__(*args, **kwargs2)
django.db.utils.OperationalError: (2026, 'SSL connection error: unknown error number')

I’ve ran out of ideas.



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

@alexandrer

I just created a new Django project using python 3 and configured the Database backend the same way yo did except for the SSL options, I left them to use defaults and it worked without any issues.

Please could you try again using my configuration? Python 3 and no SSL options.

Hope this helps

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.