SET CHARSET

2025-11-19 10:08:12  Updated

Purpose

You can use this statement to set the client and result character set.

Syntax

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

Parameters

Parameter Description
charset_name The client and result character set. Valid values:
  • utf8
  • utf8mb4
  • gbk
  • utf16
  • gb18030
DEFAULT Uses the default character set.

Examples

Set the client character set to gbk.

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

obclient> 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

Contact Us