# SET CHARACTER SET

## Syntax

```sql
SET {CHARACTER SET | CHARSET}
    {charset_name | DEFAULT}
```

## Description

Sets the [character\_set\_client](/docs/server/server-management/variables-and-modes/server-system-variables.md#character_set_client) and [character\_set\_results](/docs/server/server-management/variables-and-modes/server-system-variables.md#character_set_results) session system variables to the specified character set and [collation\_connection](/docs/server/server-management/variables-and-modes/server-system-variables.md#collation_connection) to the value of [collation\_database](/docs/server/server-management/variables-and-modes/server-system-variables.md#collation_database), which implicitly sets [character\_set\_connection](/docs/server/server-management/variables-and-modes/server-system-variables.md#character_set_connection) to the value of [character\_set\_database](/docs/server/server-management/variables-and-modes/server-system-variables.md#character_set_database).

This maps all strings sent between the current client and the server with the given mapping.

## Example

```sql
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

* [Setting Character Sets and Collations](/docs/server/reference/data-types/string-data-types/character-sets/setting-character-sets-and-collations.md)
* [SET NAMES](/docs/server/reference/sql-statements/administrative-sql-statements/set-commands/set-names.md)

<sub>*This page is licensed: CC BY-SA / Gnu FDL*</sub>

{% @marketo/form formId="4316" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mariadb.com/docs/server/reference/sql-statements/administrative-sql-statements/set-commands/set-character-set.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
