Upgrading to Ubuntu 20 Results in ERROR 2026 (HY000): SSL connection error: error:1425F102:SSL routines:ssl_choose_client_version:unsupported protocol

After upgrading Ubuntu to 20.04 and attempting to connect to MySQL, I encountered the following error:
ERROR 2026 (HY000): SSL connection error: error:1425F102:SSL routines:ssl_choose_client_version:unsupported protocol
I was unable to connect to MySQL.
This issue occurs whether I start a new EC2 instance from an Ubuntu 20.04 image or upgrade from Ubuntu 18 to 20 using do-release-upgrade. The same error appears whether I connect using the mysql command or from Django.
There is a solution on Stack Overflow:
https://stackoverflow.com/questions/61649764/mysql-error-2026-ssl-connection-error-ubuntu-20-04
1. Open the file with sudo vim /usr/lib/ssl/openssl.cnf
2. Add the following line at the beginning of the file:
openssl_conf = default_conf
3. Add the following lines at the end of the file:
[ default_conf ]
ssl_conf = ssl_sect
[ssl_sect]
system_default = ssl_default_sect
[ssl_default_sect]
MinProtocol = TLSv1
CipherString = DEFAULT:@SECLEVEL=1
This solution resolved the issue for me.
Related posts
When Connecting to a MySQL 5.7 Server Using a MySQL 8.0 Client, Charset Specification Cannot Be Done from the Client
Connecting to MySQL 8.0 with SSL Mode Disabled (ERROR 2026 (HY000): SSL Connection Error: Error Handling)
Avoid using TLS 1.2 for certain websites that freeze during HTTPS connections with Curl, Python, and PHP
After Upgrading to Django 5 and Updating Dependencies, SSL: CERTIFICATE_VERIFY_FAILED Error Occurs When Sending Emails
We look forward to discussing your development needs.