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:

Code language: JavaScript (javascript)


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


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

About Ricard Torres

Senior Front-end Software Engineer at Netcentric, 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> if you need to.