Skip to main content

SET CHARSET

Description

This statement is used to set the character set for the client and results.

Syntax

SET {CHARSET | CHARACTER SET} {DEFAULT | charset_name};

Parameters

ParameterDescription
charset_nameSpecifies the character set for the client and results. Valid values:
  • utf8
  • utf8mb4
  • gbk
  • utf16
  • gb18030
DEFAULTUses the system default character set.

Examples

Set the client character set to gbk.

SET CHARSET 'gbk';
Query OK, 0 rows affected

SHOW VARIABLES LIKE '%char%';
+--------------------------------------+---------+
| Variable_name | Value |
+--------------------------------------+---------+
| character_set_client | gbk |
| character_set_connection | utf8mb4 |
| character_set_database | utf8mb4 |
| character_set_filesystem | binary |
| character_set_results | gbk |
| character_set_server | utf8mb4 |
| character_set_system | utf8mb4 |
| validate_password_special_char_count | 0 |
+--------------------------------------+---------+
8 rows in set (0.016 sec)