Thursday, November 3, 2016

Change the Group-Office database collation and character set

Recently we converted the Group-Office database to the collation "utf8mb4_unicode_ci". We did this to support 4 byte unicode characters. Some customers may want to use another collation because of sorting in the database. For example Danish users want to use "utf8mb4_danish_ci". You can choose any collation as long as it starts with "utf8mb4".
You can use this bash script to convert all tables in the database.
Make a backup first!
#!/bin/bash
DB="go61mb4"
COLLATE="utf8mb4_unicode_ci"
USER="root"
PASSWORD="SECRET"

(
  echo 'set foreign_key_checks=0;ALTER DATABASE `'"$DB"'` \
  CHARACTER SET utf8mb4 COLLATE '"$COLLATE"';'
  mysql -u "$USER" -p"$PASSWORD"  "$DB" -e "SHOW TABLES" --batch --skip-column-names \
  | xargs -I{} echo 'ALTER TABLE `'{}'` \
  CONVERT TO CHARACTER SET utf8mb4 COLLATE '"$COLLATE"';'
) \
| mysql -u "$USER" -p"$PASSWORD" "$DB"

12 comments:

  1. Home Page
    Great tips and very easy to understand. This will definitely be very useful for me when I get a chance to start my blog.

    ReplyDelete
  2. Thank you very much for the information provided! I was looking for this data for a long time, but I was not able to find the trusted source..
    us postal address change

    ReplyDelete
  3. I regularly visit your site and find a lot of interesting information.
    Not only good posts but also great comments.
    Thank you and look forward to your page growing stronger.
    nodejs quiz , flip diving

    ReplyDelete
  4. I regularly visit your site and find a lot of interesting information.
    Not only good posts but also great comments.
    Thank you and look forward to your page growing stronger.
    nodejs quiz , flip diving

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
  6. Teracopy
    I am very comfortable and pleased to come here. Thank you very much.

    ReplyDelete
  7. I really appreciate the research you put into it..

    Best Mechanic Tool Set

    ReplyDelete