TIMEX TIMEX - 5 months ago 9
MySQL Question

In MySQL, what do I put inside my.cnf so that all tables are UTF-8 that works with emojis by default?

I'd like every table and database (to be created) to be utf-8 that works with emojis. I understand that there are a few variables I need to define inside

my.cnf
:

init_connect='SET collation_connection = ??? '
init_connect='SET NAMES ???'
character-set-server = ???
collation-server = ???


However, I'm not sure what to put in the
???
. What do I put inside
my.cnf
?

eol eol
Answer

This article may help: https://mathiasbynens.be/notes/mysql-utf8mb4#utf8-to-utf8mb4

It explains in detail how to switch to utf8mb4 to support full unicode, thus allowing emojis using the following config:

[client]
default-character-set = utf8mb4

[mysql]
default-character-set = utf8mb4

[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci