System variable description for mysql character set

  • 2020-05-09 19:23:43
  • OfStack

1. character_set_server and collation_server
These two variables are the server's character set. You can set them at system startup by -- character-set-server and -- collation-server. If not, the system sets these variables to the default values latin1 and latin1_swedish_ci. The default value is compiled in the program and can only be changed by recompiling.
These two variables are used only to provide default values for the create database command.
2. character_set_database and collation_database
These two variables are the character set of the current database. The create database command has two parameters that can be used to set the character set of the database and the comparison rules. The database setup will record the database options in the db.opt file in the database directory, where the database character set Settings are also recorded. When we change the current database with use, mysql will read the database db.opt file to set these two variables. These variables are character_set_server and collation_server when there is no current database.
These two variables are used only to provide default values for the create table command.
3.character_set_client
This variable is used to determine how mysql interprets the SQL command text that the client sends to the server.
4. character_set_connection and collation_connection
These two variables are used to determine how mysql handles the SQL command from the client. mysql transfers the SQL command text from the character_set_client encoding to character_set_connection and then executes it. collation_connection is used when comparing direct quantities in SQL.
5.character_set_results
This variable is used to determine the encoding of the text in the result sent to the client when SQL has a result returned.

There are also several character set concepts that do not have a system variable representation.
6. Character set for table
The create table parameter can be set to provide a default value for the character set of the column.
7. Character set for columns
Determines the storage encoding of the literal data for this column. Column comparison rules are higher than collation_connection. In other words, mysql will convert the text in SQL directly to the character set of the column and then compare it with the text data of the column.
8.character_set_system
This is the character set of the metadata that the database, the tables, and the columns are defined in. It has a fixed value, which is utf-8

Related articles: