# KeyCloak Backend from MySQL to MSSQL

**URL:** <https://forum.keycloak.org/t/keycloak-backend-from-mysql-to-mssql/24408>\
**Category:** Configuring the server\
**Tags:** database\
**Created:** [February 5, 2024, 3:30pm UTC](https://forum.keycloak.org/t/keycloak-backend-from-mysql-to-mssql/24408 "2024-02-05T15:30:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![arunghanta](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/arunghanta/32/5870_2.png) [@arunghanta](https://forum.keycloak.org/u/arunghanta)\
**Post date:** [February 5, 2024, 3:30pm UTC](https://forum.keycloak.org/t/keycloak-backend-from-mysql-to-mssql/24408/1 "2024-02-05T15:30:54Z")

</div>

KeyCloak Backend from MySQL to MSSQL

We’re using KeyCloak 21.x (Qurakus) with MySQL as it’s backend.  
Requirement from our Operations Team is to migrating it to MSSQL.  
Can this be achieved? Looking for some help and information on this.  
Documentation says setting it up with different DBs but I can’t find anything substantial regarding the migration of backed DB from MySQL to MSSQL.

Any help poiniting me in the right direction greatly appreciated.

---

<div class="post-metadata">

**Author:** ![xgp](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/xgp/32/2589_2.png) [@xgp](https://forum.keycloak.org/u/xgp)\
**Post date:** [February 5, 2024, 7:43pm UTC](https://forum.keycloak.org/t/keycloak-backend-from-mysql-to-mssql/24408/2 "2024-02-05T19:43:50Z")

</div>

You should look for a separate migration tool. Doing database migrations from one vendor to another is out of scope of Keycloak. However, once you migrate, both databases are supported by Keycloak.

E.g.

> **[MySQL to SQL Server: Migration guide - SQL Server](https://learn.microsoft.com/en-us/sql/sql-server/migrate/guides/mysql-to-sql-server?view=sql-server-ver16)**
>
> This guide teaches you how to migrate your MySQL databases to Microsoft SQL Server by using SQL Server Migration Assistant for MySQL (SSMA for MySQL).

> **[Home - SymmetricDS](https://symmetricds.org/)**
>
> SymmetricDS is open source database replication software that focuses on features and cross platform compatibility.

---

<div class="post-metadata">

**Author:** ![arunghanta](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/arunghanta/32/5870_2.png) [@arunghanta](https://forum.keycloak.org/u/arunghanta)\
**Post date:** [July 4, 2024, 2:01pm UTC](https://forum.keycloak.org/t/keycloak-backend-from-mysql-to-mssql/24408/3 "2024-07-04T14:01:30Z")

</div>

Our DB admin followed Microsoft’s article to migrate the DB to MSSQL. But KeyCloak is throwing this error after starting the service.

> ERROR: Violation of UNIQUE KEY constraint ‘UK\_CLI\_SCOPE’. Cannot insert duplicate key in object ‘dbo.CLIENT\_SCOPE’. The duplicate key value is (47d31f5f-35b5-4878-888a-87866ae26dda, role\_list).
> 
> 2024-04-05 11:47:04,728 WARN [com.arjuna.ats.jta] (main) ARJUNA016138: Failed to enlist XA resource io.agroal.narayana.BaseXAResource@60c8909a: javax.transaction.SystemException: TransactionImple.enlistResource - XAResource.start ARJUNA016054: could not register transaction: \< formatId=131077, gtrid\_length=35, bqual\_length=36, tx\_uid=0:ffff0ac80294:97e7:66101cf8:0, node\_name=quarkus, branch\_uid=0:ffff0ac80294:97e7:66101cf8:3f, subordinatenodename=null, eis\_name=0 \>

---

<div class="post-metadata">

**Author:** ![arunghanta](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/arunghanta/32/5870_2.png) [@arunghanta](https://forum.keycloak.org/u/arunghanta)\
**Post date:** [November 18, 2024, 7:40pm UTC](https://forum.keycloak.org/t/keycloak-backend-from-mysql-to-mssql/24408/4 "2024-11-18T19:40:44Z")

</div>

SSMA for MySQL definitely didn’t work. Tested, tried and failed. There’s a ton of errors about bit literals and all that jazz. So asking once again! Any reliable method of migrating KeyCloak background from MySQL to MSSQL?

---

<div class="post-metadata">

**Author:** ![xgp](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/xgp/32/2589_2.png) [@xgp](https://forum.keycloak.org/u/xgp)\
**Post date:** [November 18, 2024, 8:09pm UTC](https://forum.keycloak.org/t/keycloak-backend-from-mysql-to-mssql/24408/5 "2024-11-18T20:09:44Z")

</div>

No. Doing database migrations from one vendor to another is out of scope of Keycloak.
