[GH-ISSUE #717] Mysql 8 support #515

Closed
opened 2026-02-25 23:42:44 +03:00 by kerem · 5 comments
Owner

Originally created by @RonRademaker on GitHub (Oct 17, 2022).
Original GitHub issue: https://github.com/healthchecks/healthchecks/issues/717

Is it possible to run healthchecks with MySQL8? When running the docker setup, it'll crash with this message:

docker-web-1  | Traceback (most recent call last):
docker-web-1  |   File "/usr/local/lib/python3.10/site-packages/django/db/backends/base/base.py", line 282, in ensure_connection
docker-web-1  |     self.connect()
docker-web-1  |   File "/usr/local/lib/python3.10/site-packages/django/utils/asyncio.py", line 26, in inner
docker-web-1  |     return func(*args, **kwargs)
docker-web-1  |   File "/usr/local/lib/python3.10/site-packages/django/db/backends/base/base.py", line 263, in connect
docker-web-1  |     self.connection = self.get_new_connection(conn_params)
docker-web-1  |   File "/usr/local/lib/python3.10/site-packages/django/utils/asyncio.py", line 26, in inner
docker-web-1  |     return func(*args, **kwargs)
docker-web-1  |   File "/usr/local/lib/python3.10/site-packages/django/db/backends/mysql/base.py", line 247, in get_new_connection
docker-web-1  |     connection = Database.connect(**conn_params)
docker-web-1  |   File "/usr/local/lib/python3.10/site-packages/MySQLdb/__init__.py", line 123, in Connect
docker-web-1  |     return Connection(*args, **kwargs)
docker-web-1  |   File "/usr/local/lib/python3.10/site-packages/MySQLdb/connections.py", line 185, in __init__
docker-web-1  |     super().__init__(*args, **kwargs2)
docker-web-1  | MySQLdb.OperationalError: (2061, 'RSA Encryption not supported - caching_sha2_password plugin was built with GnuTLS support')

This seems to be related to the new password hashing implementation in MySQL 8

Originally created by @RonRademaker on GitHub (Oct 17, 2022). Original GitHub issue: https://github.com/healthchecks/healthchecks/issues/717 Is it possible to run healthchecks with MySQL8? When running the docker setup, it'll crash with this message: ``` docker-web-1 | Traceback (most recent call last): docker-web-1 | File "/usr/local/lib/python3.10/site-packages/django/db/backends/base/base.py", line 282, in ensure_connection docker-web-1 | self.connect() docker-web-1 | File "/usr/local/lib/python3.10/site-packages/django/utils/asyncio.py", line 26, in inner docker-web-1 | return func(*args, **kwargs) docker-web-1 | File "/usr/local/lib/python3.10/site-packages/django/db/backends/base/base.py", line 263, in connect docker-web-1 | self.connection = self.get_new_connection(conn_params) docker-web-1 | File "/usr/local/lib/python3.10/site-packages/django/utils/asyncio.py", line 26, in inner docker-web-1 | return func(*args, **kwargs) docker-web-1 | File "/usr/local/lib/python3.10/site-packages/django/db/backends/mysql/base.py", line 247, in get_new_connection docker-web-1 | connection = Database.connect(**conn_params) docker-web-1 | File "/usr/local/lib/python3.10/site-packages/MySQLdb/__init__.py", line 123, in Connect docker-web-1 | return Connection(*args, **kwargs) docker-web-1 | File "/usr/local/lib/python3.10/site-packages/MySQLdb/connections.py", line 185, in __init__ docker-web-1 | super().__init__(*args, **kwargs2) docker-web-1 | MySQLdb.OperationalError: (2061, 'RSA Encryption not supported - caching_sha2_password plugin was built with GnuTLS support') ``` This seems to be related to the new password hashing implementation in MySQL 8
kerem closed this issue 2026-02-25 23:42:44 +03:00
Author
Owner

@cuu508 commented on GitHub (Oct 18, 2022):

Yes, it should work. We're using the Django framework, and Django has official MySQL support.

Just tested the following on Ubuntu 22.04:

  • Installed MySQL server (package mysql-server-8.0)
  • Created a database user like so:
CREATE USER foo' IDENTIFIED BY 'bar';
GRANT ALL PRIVILEGES ON *.* TO 'foo'@'%' WITH GRANT OPTION;
  • As the user foo, created a database:
mysql -u foo -p
create database baz;
sudo apt-get install python3-dev default-libmysqlclient-dev build-essential
  • Installed mysqlclient inside the virtualenv:
pip install mysqlclient
  • Updated the DATABASES key in local_settings.py:
DATABASES = {
    "default": {
        "ENGINE": "django.db.backends.mysql",
        "NAME": "baz",
        "USER": "foo",
        "PASSWORD": "bar",
        "TEST": {"CHARSET": "UTF8"},
        "CONN_MAX_AGE": 60,
    }
}

At this point I could run manage.py migrate with no errors.

<!-- gh-comment-id:1281972186 --> @cuu508 commented on GitHub (Oct 18, 2022): Yes, it should work. We're using the Django framework, and Django has official MySQL support. Just tested the following on Ubuntu 22.04: * Installed MySQL server (package `mysql-server-8.0`) * Created a database user like so: ```sql CREATE USER foo' IDENTIFIED BY 'bar'; GRANT ALL PRIVILEGES ON *.* TO 'foo'@'%' WITH GRANT OPTION; ``` * As the user `foo`, created a database: ``` mysql -u foo -p create database baz; ``` * Following [mysqlclient's README](https://github.com/PyMySQL/mysqlclient#linux), installed OS dependencies for building mysqlclient: ``` sudo apt-get install python3-dev default-libmysqlclient-dev build-essential ``` * Installed mysqlclient inside the virtualenv: ``` pip install mysqlclient ``` * Updated the `DATABASES` key in `local_settings.py`: ``` DATABASES = { "default": { "ENGINE": "django.db.backends.mysql", "NAME": "baz", "USER": "foo", "PASSWORD": "bar", "TEST": {"CHARSET": "UTF8"}, "CONN_MAX_AGE": 60, } } ``` At this point I could run `manage.py migrate` with no errors.
Author
Owner

@cuu508 commented on GitHub (Oct 18, 2022):

Ah, but I get the same error when using the Docker image. Will look into this!

<!-- gh-comment-id:1281982832 --> @cuu508 commented on GitHub (Oct 18, 2022): Ah, but I get the same error when using the Docker image. Will look into this!
Author
Owner

@cuu508 commented on GitHub (Oct 18, 2022):

Looks like there isn't a quick, easy solution. The problem, as I understand it:

  • the Docker image uses Debian Buster as the base
  • on buster, default-libmysqlclient-dev depends on libmariadb-dev-compat
  • the mariadb client library, at least the version in buster, apparently doesn't support the caching_sha2_password authentication method

One experiment, to illustrate:

# start a buster container:
docker run --rm -it python:3.10-slim-buster bash
# inside the container, install the mysql command line client: 
root@9c23233cd01e:/# apt update && apt install default-mysql-client
# try to connect to MySQL 8:
root@9c23233cd01e:/# mysql -u foo -p -h 192.168.123.123 baz
Enter password: 
ERROR 2061 (HY000): RSA Encryption not supported - caching_sha2_password plugin was built with GnuTLS support

Here we don't have Healthchecks, Django, or mysqlclient-python in the mix, but still get the same error.

Possible fixes:

  • use a different base image
  • or install MySQL client libraries from MySQL APT repository

A workaround that should work for now: alter the database user to use the mysql_native_password authentication method:

ALTER USER 'foo' IDENTIFIED WITH mysql_native_password BY 'bar';
<!-- gh-comment-id:1282092476 --> @cuu508 commented on GitHub (Oct 18, 2022): Looks like there isn't a quick, easy solution. The problem, as I understand it: * the Docker image uses Debian Buster as the base * on buster, `default-libmysqlclient-dev` depends on `libmariadb-dev-compat` * the mariadb client library, at least the version in buster, apparently doesn't support the caching_sha2_password authentication method One experiment, to illustrate: ``` # start a buster container: docker run --rm -it python:3.10-slim-buster bash # inside the container, install the mysql command line client: root@9c23233cd01e:/# apt update && apt install default-mysql-client # try to connect to MySQL 8: root@9c23233cd01e:/# mysql -u foo -p -h 192.168.123.123 baz Enter password: ERROR 2061 (HY000): RSA Encryption not supported - caching_sha2_password plugin was built with GnuTLS support ``` Here we don't have Healthchecks, Django, or mysqlclient-python in the mix, but still get the same error. Possible fixes: * use a different base image * or install MySQL client libraries from MySQL APT repository A workaround that should work for now: alter the database user to use the `mysql_native_password` authentication method: ``` ALTER USER 'foo' IDENTIFIED WITH mysql_native_password BY 'bar'; ```
Author
Owner

@cuu508 commented on GitHub (Oct 18, 2022):

I've released v2.4.1, and pushed updated docker images. It should fix the MySQL 8 connection issue.

<!-- gh-comment-id:1282667448 --> @cuu508 commented on GitHub (Oct 18, 2022): I've released v2.4.1, and pushed updated docker images. It should fix the MySQL 8 connection issue.
Author
Owner

@RonRademaker commented on GitHub (Oct 20, 2022):

Thanks for the quick response and solution!

<!-- gh-comment-id:1285196404 --> @RonRademaker commented on GitHub (Oct 20, 2022): Thanks for the quick response and solution!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/healthchecks#515
No description provided.