12

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?

Vidar Vestnes
  • 42,644
  • 28
  • 86
  • 100

2 Answers2

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