I'm using mysqldump to dump my database that contains UTF8MB4 columns with UTF8MB4 data. When I import this .sql
file into a new database with UTF8MB4 support, all UTF8MB4 characters are converted into ????
. Anybody got a clue about how to make MySQL and import work with UTF8MB4?
Asked
Active
Viewed 8,060 times
12

Vidar Vestnes
- 42,644
- 28
- 86
- 100
-
Did you find an answer to this? – Jan Sverre Sep 29 '15 at 09:17
-
Related http://stackoverflow.com/questions/20216849/mysqldump-with-utf8-can-not-export-the-right-emojis-string – reallynice Jan 13 '17 at 16:31
-
The Henridv answer is correct and should be accepted, but then importing is still tricky. What worked for me: https://stackoverflow.com/a/52298202/470749 – Ryan Sep 12 '18 at 15:00
2 Answers
17
You should specify the character set with --default-character-set=utf8mb4
option when using mysqldump
.
$ mysqldump --default-character-set=utf8mb4 -uusername -p database > dump.sql

Henridv
- 766
- 12
- 23
2
Since MySQL 8.0 default charset for mysqldump is utf8mb4, so the problem should not appear anymore.
However in MySQL 5.7 default charset for mysqldump is utf8, so there you should explicitly change it as in Henridv answer (--default-character-set=utf8mb4
).

user718644
- 29
- 1
- 3