Mysqldump not exporting emojis correctly – MySQL

โš ๏ธ Problem?

When using mysqldump tool from your command line (such as my Ubuntu 18.04 server) I found the default settings were not exporting the emoji characters correctly. Wrong charset. It was leaving ??? instead of the actual emoji entity.

๐Ÿ’ก How to fix it?

Define the utf8mb4 charset when exporting your database:

--default-character-set=utf8mb4
Code language: JavaScript (javascript)

Export

mysqldump --default-character-set=utf8mb4 -u your_user -p database_name > file.sql
Code language: JavaScript (javascript)

Import

mysql -u your_user -p database_name < file.sql
Code language: CSS (css)

Leave a Reply

Add <code> Some Code </code> by using this tags.

*
*