MySQL: Encoding and collation
See database encoding
mysql> SELECT default_character_set_name FROM information_schema.SCHEMATA
WHERE schema_name = "database";
See table encoding
mysql> SELECT CCSA.character_set_name FROM information_schema.`TABLES` T,
information_schema.`COLLATION_CHARACTER_SET_APPLICABILITY` CCSA
WHERE CCSA.collation_name = T.table_collation
AND T.table_schema = "database"
AND T.table_name = "table";
See column encoding
mysql> SELECT character_set_name FROM information_schema.`COLUMNS`
WHERE table_schema = "database"
AND table_name = "table"
AND column_name = "column";
See encoding and collation variables
mysql> USE database;
mysql> SHOW variables LIKE 'character_%';
mysql> SHOW VARIABLES LIKE 'collation_%';
Change database encoding
MySQL >= 5.5
mysql> ALTER DATABASE databasename CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
Change table encoding
MySQL >= 5.5
mysql> ALTER TABLE tablename CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
Change server encoding
/etc/mysql/mysql.conf.d/mysqld.cnf:
-----------------------------------
...
# Encoding
character-set-server = utf8
_$: systemctl restart mysql.service