Search code examples
mysqlsqldatabaseutf8mb4

How to preserve UTF8mb4 data with mysqldump?


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?


Solution

  • 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