Database migration fails due to duplicate entry

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Symptoms

Error message when migrating the database (e.g. from HSQL to MySQL):

1 2 3 4 5 6 ... 76329 rows written, 40 tables completed. 76336 rows written, 41 tables completed. Database error at cru_user:121 (table:row) of the input: Duplicate entry 'abc' for key 2 Duplicate entry 'abc' for key 2 Database migration failed: java.sql.BatchUpdateException: Duplicate entry 'abc' for key 2

Cause

This problem can occur if:

  • the target database is case insensitive.

  • the target database has not been created with the correct collation.

Resolution

If the collation column is not shown as utf8_bin, you need to recreate the database with the correct collation. For more information, refer to our database migration documentation.

Updated on April 8, 2025

Still need help?

The Atlassian Community is here for you.