Unknown system variable 'query_cache_size'

Hey everyone,

actually i’m trying to install keycloak with a database on a remote mysql db cluster which is secured with ssl.

I configured the mysql client with ssl and a “normal” mysql connection is working fine with ssl:
mysql -h 10.1.201.4 -u keycloak -p -P6033

I configured keycloak as follows:

db=mysql
db-username=keycloak
db-password=supersecretpassword
db-url=jdbc:mysql://10.1.201.4:6033/keycloak
https-certificate-file=/etc/keycloak/keycloak-server.crt.pem
https-certificate-key-file=/etc/keycloak/keycloak-server.key.pem
hostname=auth.domain.lan

I created myself a systemd file for it:

[Unit]
Description=Keycloak Identity and Access Management
After=network.target

[Service]
User=keycloak
Group=keycloak
Environment="JAVA_HOME=/usr/local/jdk-22"
Environment="JBOSS_HOME=/usr/local/keycloak-25.0.4"
ExecStart=/usr/local/keycloak-25.0.4/bin/kc.sh -cf /etc/keycloak/keycloak.conf start
Restart=on-failure
LimitNOFILE=102642

[Install]
WantedBy=multi-user.target

the error when starting is:

Aug 26 07:41:12 auth kc.sh[4971]: 2024-08-26 07:41:12,344 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Failed to start server in (production) mode
Aug 26 07:41:12 auth kc.sh[4971]: 2024-08-26 07:41:12,346 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Failed to obtain JDBC connection
Aug 26 07:41:12 auth kc.sh[4971]: 2024-08-26 07:41:12,346 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Unknown system variable 'query_cache_size'
Aug 26 07:41:12 auth kc.sh[4971]: 2024-08-26 07:41:12,346 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) For more details run the same command passing the '--verbose' option. Also you can use '--help' to see the details about the usage of the particular command.

The remote database cluster is a percona xtraDB cluster - so mysql as driver should be fine. Does anyone have any idea why the error occurs?

Best regards

I have just found something about this: https://youtrack.jetbrains.com/issue/DBE-8787/DataGrip-reports-Unknown-system-variable-querycachetype-when-connecting-to-MySQL#focus=Comments-27-3698312.0-0

This is probably exactly our problem, as I use ProxySQL as middleware. I will test the workaround and report back.

//Edit
Yep, thats the solution.

P.S. Keycloak cant work when PXC Strict Mode is set to ENFORCING. We will now evaluate if we set it to PERMISSIVE.