Skip to content

Instantly share code, notes, and snippets.

@dannygsmith
Created August 31, 2017 02:02
Show Gist options
  • Save dannygsmith/b31f47bdc59402449a3c14be2b4658d7 to your computer and use it in GitHub Desktop.
Save dannygsmith/b31f47bdc59402449a3c14be2b4658d7 to your computer and use it in GitHub Desktop.
Convert database to utf8 utf8_general_ci
DB="dbname"
(
echo 'ALTER DATABASE `'"$DB"'` CHARACTER SET utf8 COLLATE utf8_general_ci;'
mysql "$DB" -e "SHOW TABLES" --batch --skip-column-names \
| xargs -I{} echo 'ALTER TABLE `'{}'` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;'
) \
| mysql "$DB"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment