Created
September 10, 2019 09:57
-
-
Save pioz/a948aeeda51a75e996f1cd3b7f1afcc7 to your computer and use it in GitHub Desktop.
Convert database charset encoding to utf8mb4 and collation to utf8mb4_unicode_ci
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
| #!/bin/bash | |
| DB="italian_spiderman" | |
| CHARSET="utf8mb4" | |
| COLL="utf8mb4_unicode_ci" | |
| echo $DB | |
| echo "ALTER DATABASE \`$DB\` CHARACTER SET $CHARSET COLLATE $COLL;" | mysql | |
| echo "USE \`$DB\`; SHOW TABLES;" | mysql -s | ( | |
| while read TABLE; do | |
| echo $DB.$TABLE | |
| echo "ALTER TABLE \`$TABLE\` CONVERT TO CHARACTER SET $CHARSET COLLATE $COLL;" | mysql $DB | |
| done | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment