MySQL Backup and Restore with UTF-8 in mind

I recently had some issues as I dumped a MySQL/MariaDB database on a Linux server and tried to import that dump on my Windows working machine.

Umlauts broke on my Windows machine but not on the Linux server where dump was created. I found a good explanation how to actually create UTF-8 aware backups:
Dumping and importing from/to MySQL in an UTF-8 safe way

  • Backup:
    Use the mysqldump option to write the output to disk, dont use the bash redirect function (mysqldump … > database.sql).

    $ mysqldump -u root -p database -r database.sql
  • Restore:
    Again, there is a better way using as using bash file reading:

    $ mysql -u root -p --default-character-set=utf8 database
    mysql> SOURCE database.sql