Question

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

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.


Submit an answer

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!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

@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