-
-
Save dannygsmith/9e5a57f5fa22f6c47723e4385142b80e to your computer and use it in GitHub Desktop.
WordPress: Script to convert MySQL collation from utf8mb4 to utf8 (via http://ben.lobaugh.net/blog/201740/script-to-convert-mysql-collation-from-utf8mb4-to-utf8)
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
DB="your_database_name" | |
USER="your_db_user" | |
PASS="your_db_pass" | |
HOST="database_hostname" | |
( | |
echo 'ALTER DATABASE `'"$DB"'` CHARACTER SET utf8 COLLATE utf8_general_ci;' | |
mysql -p $PASS -u $USER -h $HOST "$DB" -e "SHOW TABLES" --batch --skip-column-names \ | |
| xargs -I{} echo 'ALTER TABLE `'{}'` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;' | |
) \ | |
| mysql -p $PASS -u $USER -h $HOST "$DB" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment