Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- To get the script you work open your command line and use the following steps:
- nano convert_to_utf8mb4.sh
- paste the script & save
- /*************** start script *********/
- DB="database_name"
- USER="mysql_user"
- PASS="mysql_password"
- (
- echo 'ALTER DATABASE `'"$DB"'` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'
- mysql -p$PASS -u $USER "$DB" -e "SHOW TABLES" --batch --skip-column-names \
- | xargs -I{} echo 'ALTER TABLE `'{}'` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'
- ) \
- | mysql -p$PASS -u $USER "$DB"
- /********* end script **********************/
- sudo chmod 755 convert_to_utf8mb4.sh (in terminal)
- run the script by type ./convert_to_utf8mb4.sh
- Yes, collation has been changed!
Add Comment
Please, Sign In to add comment