Questions And Answers

More Tutorials

MYSQL Character Sets and Collations


There 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 subset of utf8. This excludes Emoji and some of Chinese.
utf8mb4 -- the full set of UTF8 characters, covering all current languages.

All include English characters, encoded identically. utf8 is a subset of utf8mb4.

Best practice...

.Use utf8mb4 for any TEXT or VARCHAR column 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, "UTF8" means the same things 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.

The 'latest' utf8mb4 collation is utf8mb4_unicode_520_ci, based on Unicode 5.20. If you are working with a single language, you might want, say, utf8mb4_polish_ci, which will rearrange the letters slightly, based on Polish conventions.


In this page (written and validated by ) you learned about MYSQL Character Sets and Collations . What's Next? If you are interested in completing MYSQL tutorial, your next topic will be learning about: MYSQL MyISAM Engine.

Incorrect info or code snippet? We take very seriously the accuracy of the information provided on our website. We also make sure to test all snippets and examples provided for each section. If you find any incorrect information, please send us an email about the issue:

Share On:

Mockstacks was launched to help beginners learn programming languages; the site is optimized with no Ads as, Ads might slow down the performance. We also don't track any personal information; we also don't collect any kind of data unless the user provided us a corrected information. Almost all examples have been tested. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. By using, you agree to have read and accepted our terms of use, cookies and privacy policy.