Monthly Archives: August 2022

MySQL or MariaDB and Character Sets/Collation

In MySQL and MariaDB, utf8 is not actually UTF-8 encoding. Always use utf8mb4.

To convert a table to utf8mb4:

ALTER TABLE `table_name` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

To show character set and collation variables:

 SHOW VARIABLES WHERE Variable_name LIKE '%collat%' OR Variable_name LIKE '%character%'

References: