MySQL Character Set

MySQL Character Set is the set of legal characters allowed in MySQL. All the characters set in MySQL have a collation associated with them. A Collation is basically a set of rules defining a set of rules.

A character set decides the encoding given to each character. It decides how the characters are stored in the system. The default character set for MySQL is latin1.

Show all character sets in MySQL

To see all the character Sets available, we do:

SHOW CHARACTER SET;

Convert between Character Sets in MySQL

We can convert from one character sets to another by using the CONVERT or the CAST method. The Basic method for the Convert method is

CONVERT(<expression/String> USING <character_set_name>);

Example,

select convert('vêtements' USING utf8);

The Basic syntax for Cast is,

CAST(string AS <character_type> CHARACTER SET <character_set_name>)

For example:

select CAST(_utf8 'vêtements' AS CHAR CHARACTER SET latin5);