我们以前的程序员在表(Mysql)中设置了错误的排序规则。他用拉丁排序规则设置它,它应该是 UTF8,现在我遇到了问题。每条带有中日字符的记录都变成了??? 特点。
是否可以更改排序规则并取回字符的详细信息?
更改数据库排序规则:
ALTER DATABASE <database_name> CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
更改表排序规则:
ALTER TABLE <table_name> CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
更改列排序规则:
ALTER TABLE <table_name> MODIFY <column_name> VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
utf8mb4_0900_ai_ci
3 bytes -- utf8 4 bytes -- utf8mb4 (new) v4.0 -- _unicode_ v5.20 -- _unicode_520_ v9.0 -- _0900_ (new) _bin -- just compare the bits; don't consider case folding, accents, etc _ci -- explicitly case insensitive (A=a) and implicitly accent insensitive (a=谩) _ai_ci -- explicitly case insensitive and accent insensitive _as (etc) -- accent-sensitive (etc) _bin -- simple, fast _general_ci -- fails to compare multiletters; eg ss=脽, somewhat fast ... -- slower _0900_ -- (8.0) much faster because of a rewrite