Skip to content

Instantly share code, notes, and snippets.

@shiftb
Created September 3, 2010 07:01
Show Gist options
  • Save shiftb/563533 to your computer and use it in GitHub Desktop.
Save shiftb/563533 to your computer and use it in GitHub Desktop.
A script to convert a MySQL database to UTF-8
# Found this somewhere on the intertubes.
# Posting here for future use and posterity
mysqldump --user=username --password=password --default-character-set=latin1 --skip-set-charset dbname > dump.sql
sed -r 's/latin1/utf8/g' dump.sql > dump_utf.sql
mysql --user=username --password=password --execute="DROP DATABASE dbname; CREATE DATABASE dbname CHARACTER SET utf8 COLLATE utf8_general_ci;"
mysql --user=username --password=password --default-character-set=utf8 dbname < dump_utf.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment