convert a mysql table to utf8mb4 (useful for migration to mb4 on Nextcloud)
This file contains 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 | |
# | |
# CHANGE VALUES OF DATABASE AND MYSQL TO MATCH YOUR SETUP | |
DATABASE="devncmaster" | |
MYSQL="mysql -N --database=$DATABASE" | |
# convert database with all tables to utf8mb4 | |
echo "ALTER DATABASE $DATABASE CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin;" | $MYSQL | |
echo 'show tables' | eval $MYSQL | while read table | |
do | |
echo "ALTER TABLE $table ROW_FORMAT=DYNAMIC;" | | |
eval $MYSQL | |
echo "ALTER TABLE $table CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;" | | |
eval $MYSQL | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment