# Configuring MySQL with KeyCloak

**URL:** <https://forum.keycloak.org/t/configuring-mysql-with-keycloak/7835>\
**Category:** Configuring the server\
**Created:** [March 9, 2021, 4:57pm UTC](https://forum.keycloak.org/t/configuring-mysql-with-keycloak/7835 "2021-03-09T16:57:22Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thato-Moloi](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/thato-moloi/32/2584_2.png) [@Thato-Moloi](https://forum.keycloak.org/u/Thato-Moloi)\
**Post date:** [March 9, 2021, 4:57pm UTC](https://forum.keycloak.org/t/configuring-mysql-with-keycloak/7835/1 "2021-03-09T16:57:22Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Thato-Moloi](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/thato-moloi/32/2584_2.png) [@Thato-Moloi](https://forum.keycloak.org/u/Thato-Moloi)\
**Post date:** [March 9, 2021, 5:39pm UTC](https://forum.keycloak.org/t/configuring-mysql-with-keycloak/7835/2 "2021-03-09T17:39:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![lokesharma95](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/lokesharma95/32/2586_2.png) [@lokesharma95](https://forum.keycloak.org/u/lokesharma95)\
**Post date:** [March 10, 2021, 10:06am UTC](https://forum.keycloak.org/t/configuring-mysql-with-keycloak/7835/3 "2021-03-10T10:06:12Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Thato-Moloi](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/thato-moloi/32/2584_2.png) [@Thato-Moloi](https://forum.keycloak.org/u/Thato-Moloi)\
**Post date:** [March 10, 2021, 8:13pm UTC](https://forum.keycloak.org/t/configuring-mysql-with-keycloak/7835/4 "2021-03-10T20:13:14Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![lokesharma95](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/lokesharma95/32/2586_2.png) [@lokesharma95](https://forum.keycloak.org/u/lokesharma95)\
**Post date:** [March 10, 2021, 8:34pm UTC](https://forum.keycloak.org/t/configuring-mysql-with-keycloak/7835/5 "2021-03-10T20:34:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Thato-Moloi](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/thato-moloi/32/2584_2.png) [@Thato-Moloi](https://forum.keycloak.org/u/Thato-Moloi)\
**Post date:** [March 10, 2021, 8:57pm UTC](https://forum.keycloak.org/t/configuring-mysql-with-keycloak/7835/6 "2021-03-10T20:57:18Z")

</div>

Just follow this tutorial: [https://www.tutorialsbuddy.com/keycloak-mysql-setup](https://www.tutorialsbuddy.com/keycloak-mysql-setup)

I used it and it answers all your questions.

---

<div class="post-metadata">

**Author:** ![lokesharma95](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/lokesharma95/32/2586_2.png) [@lokesharma95](https://forum.keycloak.org/u/lokesharma95)\
**Post date:** [March 12, 2021, 5:43am UTC](https://forum.keycloak.org/t/configuring-mysql-with-keycloak/7835/7 "2021-03-12T05:43:29Z")

</div>

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