Advertisement
Guest User

Untitled

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