Guest User

Untitled

a guest
Oct 8th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. To get the script you work open your command line and use the following steps:
  2.  
  3. nano convert_to_utf8mb4.sh
  4.  
  5. paste the script & save
  6.  
  7. /*************** start script *********/
  8. DB="database_name"
  9. USER="mysql_user"
  10. PASS="mysql_password"
  11. (
  12. echo 'ALTER DATABASE `'"$DB"'` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'
  13. mysql -p$PASS -u $USER "$DB" -e "SHOW TABLES" --batch --skip-column-names \
  14. | xargs -I{} echo 'ALTER TABLE `'{}'` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'
  15. ) \
  16. | mysql -p$PASS -u $USER "$DB"
  17. /********* end script **********************/
  18.  
  19. sudo chmod 755 convert_to_utf8mb4.sh (in terminal)
  20.  
  21. run the script by type ./convert_to_utf8mb4.sh
  22.  
  23. Yes, collation has been changed!
Add Comment
Please, Sign In to add comment