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=utf8mb4Code language: JavaScript (javascript)

Export

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

Import

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

Leave a Reply

Your email address will not be published. Required fields are marked *