Which CHARACTER SET and COLLATION
suggest changeThere are dozens of character sets with hundreds of collations. (A given collation belongs to only one character set.) See the output of SHOW COLLATION;.
There are usually only 4 CHARACTER SETs that matter:
ascii -- basic 7-bit codes.
latin1 -- ascii, plus most characters needed for Western European languages.
utf8 -- the 1-, 2-, and 3-byte encoding utf8mb3. It excludes emoji and some Chinese characters.
utf8mb4 -- the full UTF-8 encoding, covering all current languages.
All include English characters, encoded identically. utf8 is a subset of utf8mb4.
Best practice…
- Use utf8mb4 for any
TEXTorVARCHARcolumn that can have a variety of languages in it. - Use ascii (latin1 is ok) for hex strings (UUID, MD5, etc) and simple codes (country_code, postal_code, etc).
utf8mb4 did not exist until version 5.5.3, so utf8 was the best available before that.
Outside of MySQL, “UTF-8” means the same thing as MySQL’s utf8mb4, not MySQL’s utf8.
Collations start with the charset name and usually end with _ci for “case and accent insensitive” or _bin for “simply compare the bits.”
In MySQL 5.7, utf8mb4_unicode_520_ci follows Unicode 5.2.0. MySQL 8.0 defaults to utf8mb4_0900_ai_ci. For one language you might want, for example, utf8mb4_polish_ci.