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
you specify only a character set (for example,
latin1) but not a collation, that is the same
latin1_swedish_ci is the default
latin1. Therefore, the
following three commands all have the same effect:
mysqld mysqld --character-set-server=latin1 mysqld --character-set-server=latin1 \ --collation-server=latin1_swedish_ci
One way to change the settings is by recompiling. To change the
default server character set and collation when building from
sources, use the
DEFAULT_COLLATION options for
CMake. For example:
cmake . -DDEFAULT_CHARSET=latin1
cmake . -DDEFAULT_CHARSET=latin1 \ -DDEFAULT_COLLATION=latin1_german1_ci
Both mysqld and CMake 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
statements. They have no other purpose.