Configuring MySQL with KeyCloak

Hi. I followed the documentation and numerous examples to use MySQL as a database instead of the in memory database. Executing the standalone.bat for the first time after the configuration works, but if I stop keycloak and try to run the standalone.bat again file I get errors. I’ve tried setting “migration” to manual, and “intialiseifempty” to false, but I still get errors. My database always has to be empty for it work. I’ve even tried adding the tables manually with the update script that keycloak generates, but keycloak only works if it creates it’s tables. I get errors like this :

18:37:57,271 ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool – 48) WFLYCTL0190: Step handler org.jboss.as.security.SecurityDomainAdd$1@ad4cda9 for operation add at address [
(“subsystem” => “security”),
(“security-domain” => “jboss-ejb-policy”).

Please help.

1 Like

I found the answer. I changed the jdbc connector for mysql to an older version and it worked.

hi could you please provide the more information on this as i am also having trouble with this part. like what version keycloak you have used and what version mysql connector you have used and your standalone.xml code?

I changed my sql connector to an old version, which is 10.0.21. Don’t use the latest version of mysql connector. My keycloak version is the latest one.

1 Like

And where do you store your module.xml file? In keycloak/org or keycloak/com. And can you please share your standalone.xml code, it will be a lot helpful. Thanks in advance

Just follow this tutorial: https://www.tutorialsbuddy.com/keycloak-mysql-setup

I used it and it answers all your questions.

1 Like

Thanks a ton bro. it worked for me as well i used 8.0.21 jdbc