Reputation: 10228
Here is the command I use:
ALTER TABLE <table_name> MODIFY <column_name> VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
It works well. Now I need to set utf8mb4_unicode_ci
for a column (since currently characters are shown as ???
). Anyway here is my new command:
ALTER TABLE <table_name> MODIFY <column_name> VARCHAR(255) CHARACTER SET utf8 COLLATE utf8mb4_unicode_ci;
But sadly MySQL throws:
ERROacR 1253 (42000): COLLATION 'utf8mb4_unicode_ci' is not valid for CHARACTER
Any idea?
Upvotes: 0
Views: 655
Reputation: 142518
The first part of the COLLATION
name must match the CHARACTER SET
name.
CHARACTER SET utf8mb4
is needed for Emoji and some Chinese characters.
Let's back up to the 'real' problem -- of question marks.
COLLATION
refers to the rules of ordering and sorting, not encoding.
CHARACTER SET
refers to the encoding. This should be consistent at all stages. Question Marks come from inconsistencies.
Trouble with UTF-8 characters; what I see is not what I stored points out that these are the likely suspects for Question Marks:
Upvotes: 1
Reputation: 10228
This worked for me:
ALTER TABLE <table_name> MODIFY <column_name> VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
Upvotes: 0