MySQL and Keycloak setup

Hello I am trying to add mysql database in my Keycloak server.

I've added module.xml and mysql-connector-java-5.1.42-bin.jar under /modules/system/layers/base/com/mysql/main.

When I am running the command to add mysql module, ./jboss-cli.sh, it errors out with

Exception in thread "CLI Terminal Connection (uninterruptable)" java.lang.ArithmeticException: / by zero

And when i am trying to start Keycloak, I am also notified that there is a missing service.

service jboss.jdbc-driver.mysql (missing)

Please help!!

Asked By: deji04
||

Answer #1:

There is an error in the Keycloak documentation. Driver should be in the

modules/system/layers/base/com/mysql/driver/main

folder.

The full valid instruction is here

https://github.com/v-ladynev/keycloak-nodejs-example#keycloak-configuration

Also you can use docker images to experiment

https://github.com/v-ladynev/keycloak-nodejs-example#keycloak-docker-image

Answered By: v.ladynev

Answer #2:

When I am running the command to add mysql module, ./jboss-cli.sh, it errors out with

Can you post your Command? You dont't have to do this with the cli. It's also possible to modify the config in a editor. At least for testing you should try this.

Keycloak docs have a pretty good part about database setup: https://www.keycloak.org/docs/latest/server_installation/index.html#_database

The basic steps are:

  1. Locate and download a JDBC driver for your database
  2. Package the driver JAR into a module and install this module into the server (module.xml)
  3. Declare the JDBC driver in the configuration profile of the server (standalone.xml)
  4. Modify the datasource configuration to use your database’s JDBC driver
  5. Modify the datasource configuration to define the connection parameters to your database
Answered By: flxPeters
The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .



# More Articles