Skip to content

Instantly share code, notes, and snippets.

@samsargent
Created March 7, 2016 04:54
Show Gist options
  • Save samsargent/244e0a66a7cf9134d884 to your computer and use it in GitHub Desktop.
Save samsargent/244e0a66a7cf9134d884 to your computer and use it in GitHub Desktop.
Bulk update to utf8/utf8_general_ci database + tables
DB="DBNAME"; ( echo 'ALTER DATABASE `'"$DB"'` CHARACTER SET utf8 COLLATE utf8_general_ci;'; mysql -u root "$DB" -e "SHOW TABLES" --batch --skip-column-names | xargs -I{} echo 'ALTER TABLE `'{}'` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;' ) | mysql -u root "$DB"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment