Показать/сменить кодировку MySQL/MariaDB



Просмотр установленных кодировок

mysql> SHOW VARIABLES LIKE 'char%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | utf8                       |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | utf8                       |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)

Установить явно при создании базы данных

CREATE DATABASE db_name CHARACTER SET utf8 COLLATE utf8_unicode_ci;

Глобально через файл my.cnf

[mysqld]
init_connect='SET NAMES utf8'
character_set_server=utf8
collation-server=utf8_general_ci