如果JIRA MySQL字符集设置的不正确,需要修改字符集为utf8mb4, collation为utf8mb4_bin. 需求修改以下几个方面,
SET FOREIGN_KEY_CHECKS=0;
//To Change database collation
ALTER DATABASE jiradb CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
//To change table collation:
SELECT CONCAT('ALTER TABLE `', table_name, '` CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;')
FROM information_schema.TABLES AS T, information_schema.`COLLATION_CHARACTER_SET_APPLICABILITY` AS C
WHERE C.collation_name = T.table_collation
AND T.table_schema = 'jiradb'
AND
(
C.CHARACTER_SET_NAME != 'utf8mb4'
OR
C.COLLATION_NAME != 'utf8mb4_bin'
);
//上面语句生成的是修改表编码的SQL语句, 批量拷贝这些语句再执行
//To change column collation for varchar columns:
SELECT CONCAT('ALTER TABLE `', table_name, '` MODIFY `', column_name, '` ', DATA_TYPE, '(', CHARACTER_MAXIMUM_LENGTH, ') CHARACTER SET utf8mb4 COLLATE utf8mb4_bin', (CASE WHEN IS_NULLABLE = 'NO' THEN ' NOT NULL' ELSE '' END), ';')
FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = 'jiradb'
AND DATA_TYPE = 'varchar'
AND
(
CHARACTER_SET_NAME != 'utf8mb4'
OR
COLLATION_NAME != 'utf8mb4_bin'
);
//上面语句生成的是修改表中数据编码的SQL语句, 批量拷贝这些语句再执行
//To change column collation for non-varchar columns:
SELECT CONCAT('ALTER TABLE `', table_name, '` MODIFY `', column_name, '` ', DATA_TYPE, ' CHARACTER SET utf8mb4 COLLATE utf8mb4_bin', (CASE WHEN IS_NULLABLE = 'NO' THEN ' NOT NULL' ELSE '' END), ';')
FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = 'jiradb'
AND DATA_TYPE != 'varchar'
AND
(
CHARACTER_SET_NAME != 'utf8mb4'
OR
COLLATION_NAME != 'utf8mb4_bin'
);
//上面语句生成的是修改表中数据编码的SQL语句, 批量拷贝这些语句再执行
SET FOREIGN_KEY_CHECKS=1;
SQL