Skip to content

Instantly share code, notes, and snippets.

@peterdalle
Created August 21, 2015 18:36
Show Gist options
  • Save peterdalle/0b6952dcd28aaacb5c1d to your computer and use it in GitHub Desktop.
Save peterdalle/0b6952dcd28aaacb5c1d to your computer and use it in GitHub Desktop.
Convert MySQL tables to UTF-8 collation in Bash
mysql --database=dbname -B -N -e "SHOW TABLES" \
| awk '{print "SET foreign_key_checks = 0; ALTER TABLE", $1, "CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; SET foreign_key_checks = 1; "}' \
| mysql --database=dbname &
# http://stackoverflow.com/questions/105572/a-script-to-change-all-tables-and-fields-to-the-utf-8-bin-collation-in-mysql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment