SET CHARACTER SET
Map strings to a specific character set. This command updates the character set for the client, results, and connection to ensure correct data encoding.
Syntax
SET {CHARACTER SET | CHARSET} {charset_name | DEFAULT}Description
Sets the character_set_client and character_set_results session system variables to the specified character set and collation_connection to the value of collation_database, which implicitly sets character_set_connection to the value of character_set_database.
This maps all strings sent between the current client and the server with the given mapping.
Example
SHOW VARIABLES LIKE 'character_set\_%'; +--------------------------+--------+ | Variable_name | Value | +--------------------------+--------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | latin1 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | latin1 | | character_set_system | utf8 | +--------------------------+--------+ SHOW VARIABLES LIKE 'collation%'; +----------------------+-------------------+ | Variable_name | Value | +----------------------+-------------------+ | collation_connection | utf8_general_ci | | collation_database | latin1_swedish_ci | | collation_server | latin1_swedish_ci | +----------------------+-------------------+ SET CHARACTER SET utf8mb4; SHOW VARIABLES LIKE 'character_set\_%'; +--------------------------+---------+ | Variable_name | Value | +--------------------------+---------+ | character_set_client | utf8mb4 | | character_set_connection | latin1 | | character_set_database | latin1 | | character_set_filesystem | binary | | character_set_results | utf8mb4 | | character_set_server | latin1 | | character_set_system | utf8 | +--------------------------+---------+ SHOW VARIABLES LIKE 'collation%'; +----------------------+-------------------+ | Variable_name | Value | +----------------------+-------------------+ | collation_connection | latin1_swedish_ci | | collation_database | latin1_swedish_ci | | collation_server | latin1_swedish_ci | +----------------------+-------------------+See Also
This page is licensed: CC BY-SA / Gnu FDL
Last updated
Was this helpful?
.png?alt=media&token=7e7f4c73-9972-4e67-9a1a-74dc18591022&width=260&dpr=4&quality=100&sign=760f8d93&sv=2)
.png?alt=media&token=ee5a45b3-d05b-4bb5-97d0-0f25c5eeb110&width=260&dpr=4&quality=100&sign=12bc3702&sv=2)