Documentation Home
MySQL 5.7 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 37.8Mb
PDF (A4) - 37.8Mb
PDF (RPM) - 36.4Mb
HTML Download (TGZ) - 9.8Mb
HTML Download (Zip) - 9.9Mb
HTML Download (RPM) - 8.6Mb
Man Pages (TGZ) - 209.5Kb
Man Pages (Zip) - 318.7Kb
Info (Gzip) - 3.5Mb
Info (Zip) - 3.5Mb
Excerpts from this Manual

MySQL 5.7 Reference Manual  /  Character Sets, Collations, Unicode  /  Specifying Character Sets and Collations

10.3 Specifying Character Sets and Collations

There are default settings for character sets and collations at four levels: server, database, table, and column. The description in the following sections may appear complex, but it has been found in practice that multiple-level defaulting leads to natural and obvious results.

CHARACTER SET is used in clauses that specify a character set. CHARSET can be used as a synonym for CHARACTER SET.

Character set issues affect not only data storage, but also communication between client programs and the MySQL server. If you want the client program to communicate with the server using a character set different from the default, you'll need to indicate which one. For example, to use the utf8 Unicode character set, issue this statement after connecting to the server:

SET NAMES 'utf8';

For more information about character set-related issues in client/server communication, see Section 10.4, “Connection Character Sets and Collations”.

User Comments
  Posted by Yahoo Serious on June 13, 2006
Note that if you specify the same default character set on a lower level but without a default collation, the default collation will be the one of the character set, not the one of the higher level. So this overrides your previous default collation.

Suppose you have specified a default character set for your database, e.g. 'latin1', with a (deviating) default collation ('latin1_bin'). Now you create a table with default character set 'latin1', but no default collation. The default collation of the table will now be the one of the character set ('latin1_swedish_ci'), and not the one you used on the higher level as default collation for the same character set ('latin1_bin'). (Established in MySQL 4.1)

  Posted by time e.less on October 14, 2009
Please add the information about skip-character-set-client-handshake into every page that references server character set and collation.

I'm amazed this startup option is hidden so deep in the documentation, since it seems like many administrators who specify alternate character sets on startup would want the clients to use the server character sets when possible.

Here's an example for the [mysqld] section of your my.cnf:

> skip-character-set-client-handshake
> collation_server=utf8_unicode_ci
> character_set_server=utf8

Sign Up Login You must be logged in to post a comment.