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

Export

mysqldump --default-character-set=utf8mb4 -u your_user -p database_name > file.sql

Import

mysql -u your_user -p database_name < file.sql 

About Ricard Torres

Senior Front-end Software Engineer from Barcelona, Haidong Gumdo Instructor (korean martial art of the sword), street photographer, travel lover, TV addict, Boston Red Sox fan, and privacy advocate.

@ricard_dev @ricard_dev

📝 Blog 🎙 Podcast

Leave a Reply

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

*
*