
Pull Requests
November 15, 2019
Working With Eloquent: API Resources In Laravel – Part 2
November 29, 2019
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:
DATABASES = { | |
'default': { | |
'ENGINE': 'mysql.connector.django', | |
'NAME': '****', | |
'USER': '****', | |
'PASSWORD': '****', | |
'HOST': '****', | |
'PORT': '****', | |
'OPTIONS': { | |
"use_pure": True | |
} | |
} | |
} |
1 Comment
I’ve been going through a lot of articles… finally this solved my problem. Thank you very much!!