0
votes

How to support emoji in Azure mysql database? I tried folowing steps. but emoji is not getting inserted into database. It works when I run "SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci;" for a session only. I need to set it globally so that java application can insert emoji character to azure mysql database.

SET NAMES utf8mb4; ALTER DATABASE database_name CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;

ALTER TABLE table_name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

1

1 Answers

1
votes

When you create a database on MySQL Database on Azure, the database adopts the UTF8 character set by default unless otherwise specified. Because the UTF8 character set on MySQL supports at most 3-byte encoding, the emoji icons that are encoded by 4 bytes cannot be inserted into the table.

You will have to edit character set, and select utf8mb4 as the character set for the database.