Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.Original topic: 转换字符集失败
【TiDB Usage Environment】Production
【TiDB Version】v6.1.0
【Encountered Problem】
【Reproduction Path】What operations were performed to encounter the problem
【Problem Phenomenon and Impact】
The problem is as follows: the default TiDB character set rule is utf8mb4_bin, and now it needs to be changed to utf8mb4_general_ci. The error is as follows:
mysql> show index from xxxxx
+----------------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+-----------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Visible | Expression | Clustered |
+----------------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+-----------+
| xxx | 0 | PRIMARY | 1 | id | A | 0 | NULL | NULL | | BTREE | | | YES | NULL | YES |
| xxx | 0 | unq_e_code | 1 | e_code | A | 0 | NULL | NULL | | BTREE | | | YES | NULL | NO |
+----------------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+-----------+
2 rows in set (0.01 sec)
mysql>
mysql> alter table xxxx convert to character set utf8mb4 collate utf8mb4_general_ci;
ERROR 8200 (HY000): Unsupported converting collation of column 'e_code' from 'utf8mb4_bin' to 'utf8mb4_general_ci' when index is defined on it.