To set the default to UTF-8, you want to add the following to my.cnf/my.ini
[client]
default-character-set=utf8mb4
[mysql]
default-character-set=utf8mb4
[mysqld]
collation-server = utf8mb4_unicode_520_ci
init-connect="SET NAMES utf8mb4"
character-set-server = utf8mb4
If you want to change the character set for an existing DB, let me know… your question didn’t specify it directly so I am not sure if that’s what you want to do.
Edit: I replaced utf8
with utf8mb4
in the original answer due to utf8
only being a subset of UTF-8. MySQL and MariaDB both call UTF-8 utf8mb4
.