[keycloak-user] adding mysql or mariadb backend

Andrew Meyer andrewm659 at yahoo.com
Tue Mar 19 16:43:38 EDT 2019


Hello,If I am adding a mariadb or mysql backend to keycloak v4.8.3 or 5.0.0 what is the correct syntax from the jboss-cli.sh tool?   This is what I have in my notes.
Open the Jboss CLI and add the MySQL driver (you don't have to connect with the Jboss websocket).
$ ./bin/jboss-cli.sh Is this the correct mysql connector version for MariaDB 10.1.x?MySQL/MariaDBjboss-cli$ module add --name=com.mysql  --dependencies=javax.api,javax.transaction.api --resources=/root/mysql-connector-java-5.1.47.jar

Add the Database driver to the configuration.
MySQL/MariaDB# sudo su -
Is this the correct syntax for the driver?  Should it be com.mysql or org.mysql??
$ sudo -u keycloak ./bin/jboss-cli.sh 'embed-server,/subsystem=datasources/jdbc-driver=mysql:add(driver-name=mysql,driver-module-name=com.mysql,driver-class-name=com.mysql.jdbc.Driver)'

Remove the h2 KeycloakDS data source and add the MySQL KeycloakDS data source. (Don't delete the test database and change YOURPASS to something random)
MySQL/MariaDB
# sudo su -$ sudo -u keycloak ./bin/jboss-cli.sh 'embed-server,/subsystem=datasources/data-source=KeycloakDS:remove'
$ sudo -u keycloak ./bin/jboss-cli.sh 'embed-server,/subsystem=datasources/data-source=asmDS:add(driver-name=com.mysql,enabled=true,use-java-context=true,connection-url="jdbc:mysql://10.150.10.20:3306/keycloak?useSSL=false&useLegacyDatetimeCode=false&serverTimezone=America/Chicago&characterEncoding=UTF-8",jndi-name="java:/jboss/datasources/KeycloakDS",user-name=keycloak,password="ChangeMe",valid-connection-checker-class-name=org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker,validate-on-match=true,exception-sorter-class-name=org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker)'
$ sudo -u keycloak ./bin/jboss-cli.sh 'embed-server,/subsystem=datasources/data-source=asmDS:test-connection-in-pool'


More information about the keycloak-user mailing list