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: