Skip to main content

Default Character Set and Collation

By default, the character set and collation are set to utf8 and utf8_general_ci, respectively, across the cluster. You can override the default values by setting engine variables, which is explained in the next section. Each database and its schema objects use the cluster-wide character set and collation by default.

Executing the following SELECT statements will show the current character set and collation:

SELECT @@character_set_database;
+--------------------------+
| @@character_set_database |
+--------------------------+
| utf8                     |
+--------------------------+
SELECT @@collation_server;
+--------------------+
| @@collation_server |
+--------------------+
| utf8_general_ci    |
+--------------------+

Changing the Default Character Set and Collation

An application might require characters or collations that are not supported by the default settings; e.g., emojis or full-text search. In these cases, the default settings can be changed.

Both the default character set and collation can be reset via engine variables. When making changes to these settings, be sure to also flush the connection pools, which shut down all existing connections and close any idle pooled connections. If you do not flush the connection pools, your cluster might retain pre-existing connections, and your queries using those connections could fail.

  • Changing the default character set to "utf8mb4":

    SET GLOBAL character_set_database = 'utf8mb4';
  • Changing the collation to "utf8mb4_unicode_ci":

    SET GLOBAL collation_server = 'utf8mb4_unicode_ci';
  • Flushing the connection pools:

    FLUSH CONNECTION POOLS;