Prevent data corruption when dumping MySQL databases with utf8mb4 data

MySQL's default character set is utf8. This does not cover 4-byte characters, such as emojis. That's why utf8mb4 is commonly used instead.

When using mysqldump on such a database, one must be careful to explicitly export the data as utf8mb4—otherwise an import will give you corrupted records.

You might never notice, unless you're using WordPress and records contain a serialized representations of PHP strings, where the deserialization breaks when the string length changes.

mysqldump --default-character-set=utf8mb4