Skip to content

Instantly share code, notes, and snippets.

@mchoiruln
Last active February 12, 2019 11:12
Show Gist options
  • Save mchoiruln/b21d01c2872c8de40bb4ac1df849fd95 to your computer and use it in GitHub Desktop.
Save mchoiruln/b21d01c2872c8de40bb4ac1df849fd95 to your computer and use it in GitHub Desktop.
Dumping and importing from/to MySQL/MariaDb in an UTF-8 safe way

Dumping safely

cd to your backup dir first

mysqldump -uroot -p [database?] -r [name_dump_file?].dump
[enter password]

Importing a dump safely

find dump file or cd to dir location

mysql -uroot -p --default-character-set=utf8 [database?]
[enter password]
mysql> SET names 'utf8';
mysql> SOURCE [name_dump_file?].dump;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment