Created
August 21, 2015 18:36
-
-
Save peterdalle/0b6952dcd28aaacb5c1d to your computer and use it in GitHub Desktop.
Convert MySQL tables to UTF-8 collation in Bash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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