MySQL by default only uses a three byte encoding and so values in the four byte range (eg. Asian characters and Emojis) can not be stored. MySQL does provide full four byte UTF-8 support, but it requires certain database settings to be configured.
‘utf8_unicode_ci’ was the recommended collation. We now recommend using ‘utf8mb4_unicode_ci’ which supports four byte characters (utf8_unicode_ci only supports three).
If you want to save emojis in MySQL/MariaDB database:
Database and table’s charset must be: utf8mb4_unicode_ci
Connection also needs to be utf8mb4 not utf8 for it to work
utf8mb4_unicode_ci is based on the official Unicode rules for universal sorting and comparison, which sorts accurately in a wide range of languages.
utf8mb4_general_ci is a simplified set of sorting rules which aims to do as well as it can while taking many short-cuts designed to improve speed. It does not follow the Unicode rules and will result in undesirable sorting or comparison in some situations, such as when using particular languages or characters.