Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: TIDB 6.0如何全局设置排序规则utf8mb4_general_ci
How to globally set the collation to utf8mb4_general_ci in TIDB 6.0?
The new collation rule is enabled by default.
CREATE DATABASE db_name CHARACTER SET utf8mb4_general_ci
It should be the same as MySQL. Try the system variable collation_server.
The database has already been built, upgraded from TiDB 5.3 to 6.1.
Teacher, could you explain in more detail? Is it the command set collation_server=utf8mb4_general_ci
? I tried it, but it didn’t work.
set global collation_server=utf8mb4_general_ci;
If the collation is not specified when creating the database, it will use this collation to create the database. If the database has already been created, then if the collation is not specified when creating a table, it will inherit the collation of the database.
Currently, TiDB cannot set the character set and collation globally; it can only be specified at the database level. This should be considered a bug. For more details, you can refer to this issue: create database should use `collation_server` collation if it not specified · Issue #23199 · pingcap/tidb · GitHub
No issues found in v5.4.0 testing.
Indeed, I tested it on page 5.4.1 and there was no issue. So, this problem can be resolved by setting it globally. It’s strange why the issue hasn’t been closed.
Yes, it’s similar to MySQL.
This topic was automatically closed 60 days after the last reply. No new replies are allowed.