Convert non-UTF-8 MySQL database to UTF-8
Platform Notice: Data Center Only - This article only applies to Atlassian apps 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
Summary
Database upgrades may fail due to a wrong character set usage. This article explains how to convert a non-UTF-8 MySQL database into the recommended UTF-8 database.
Always back up your data before making any database modifications. If possible, test any alter, insert, update, or delete SQL commands on a staging server first.
Solution
Let's suppose the database is using
latin1character set andlatin1_general_cscollation:CREATE DATABASE dbname CHARACTER SET latin1 COLLATE latin1_general_cs;Make sure that Fisheye / Crucible is not running;
Connect to the database being used by Fisheye / Crucible;
Create a database dump:
mysqldump --opt -u root -p<secret> dbname > dbname.sqlOpen the resulting
dbname.sqlfile and replace all occurrences oflatin1_general_csbyutf8_binand all occurrences oflatin1byutf8, through find / replace, then save changes.Restore
dbname.sql. There are two possibilities here:Restore into a new database name, if you want to keep the original database untouched. This consists in:
Creating a new database, this time using the correct character set and collation:
CREATE DATABASE newdbname CHARACTER SET utf8 COLLATE utf8_bin;Restoring the dump:
mysql -u root -p<secret> newdbname < dbname.sql
Restore into the existing database name, if you're sure that the manual changes in
dbname.sqlthrough find / replace are correct. This consists in:Deleting the current database
dbname:DROP DATABASE dbname;Creating it again, this time using the correct character set and collation:
CREATE DATABASE dbname CHARACTER SET utf8 COLLATE utf8_bin;Restoring the dump:
mysql -u root -p<secret> dbname < dbname.sql
Restart MySQL service
Start Fisheye / Crucible
Was this helpful?