pull requests

Pull Requests

November 15, 2019
laravel eloquent

Working With Eloquent: API Resources In Laravel – Part 2

November 29, 2019

Getting Django To Talk To MySQL 8

November 19, 2019 / Tielman Janse van Vuuren

Recently I needed to move a Django database from MySQL 5.7 to MySQL 8. DigitalOcean currently only offers MySQL version 8 as a managed database. I moved the data from the old db to the new db using mysqldump and tried to connect to the database from Django when I got this error: ERROR 2026 (HY000): SSL connection error:

After searching for this error, it turns out it’s caused by using a MySQL 5.7 client to connect to a MySQL 8 database. So I tried upgrading the standard mysqlclient packages in my django project but that didn’t work. It still returned the same error.
It turns out there is a different mysql pip package for python that supports MySQL 8 so I installed the new package:
pip uninstall mysqlclient
pip install mysql-connector-python

I only had to make 2 changes to the settings.py file to get it to work: The Database ENGINE which changed to ‘mysql.connector.django’, and Adding an ‘OPTIONS’ key with ‘use_pure’: True.

Below is what the DATABASES dictionary looks like in settings.py:

https://gist.github.com/tmanOC/29eecea6a37e295459513ea29ca714b6

Share

Tielman Janse van Vuuren

Tielman is an experienced mobile and backend developer. Quality is his motto, no matter what programming language or platform.

Getting Django To Talk To MySQL 8
This website uses cookies to improve your experience. By using this website you agree to our Data Protection Policy.
Read more