SHARE
TWEET

Untitled

a guest Dec 29th, 2016 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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!
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top