MySQL 5.1 Reference Manual  /  ...  /  Server Character Set and Collation Server Character Set and Collation

MySQL Server has a server character set and a server collation. These can be set at server startup on the command line or in an option file and changed at runtime.

Initially, the server character set and collation depend on the options that you use when you start mysqld. You can use --character-set-server for the character set. Along with it, you can add --collation-server for the collation. If you don't specify a character set, that is the same as saying --character-set-server=latin1. If you specify only a character set (for example, latin1) but not a collation, that is the same as saying --character-set-server=latin1 --collation-server=latin1_swedish_ci because latin1_swedish_ci is the default collation for latin1. Therefore, the following three commands all have the same effect:

shell> mysqld
shell> mysqld --character-set-server=latin1
shell> mysqld --character-set-server=latin1 \

One way to change the settings is by recompiling. If you want to change the default server character set and collation when building from sources, use: --with-charset and --with-collation as arguments for configure. For example:

shell> ./configure --with-charset=latin1


shell> ./configure --with-charset=latin1 \

Both mysqld and configure verify that the character set/collation combination is valid. If not, each program displays an error message and terminates.

The server character set and collation are used as default values if the database character set and collation are not specified in CREATE DATABASE statements. They have no other purpose.

The current server character set and collation can be determined from the values of the character_set_server and collation_server system variables. These variables can be changed at runtime.

Download this Manual
User Comments
  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

  Posted by Dan Vashchilenko on June 28, 2012

I suppose you mean to add this to your my.cnf:

This will actually force the server and the client to use UTF8.
Sign Up Login You must be logged in to post a comment.