2015年9月16日 星期三

Upgrade MySQL Charset utf8 to utf8mb4

Upgrade MySQL Charset utf8 to utf8mb4

For UTF-8 encoding, MySQL originally use charset utf8 which is with maximum length of 3 bytes for every character to cover 65536 unicode characters; from version 5.5.3, MySQL implements a new charset utf8mb4 which is with maximu length of 4 bytes for every character to support full UTF-8 encoding unicode characters.

For a good multilingual support in modern international internet environment, it's better to upgrade MySQL charset utf8 to utf8mb4 from now on. Also it better to change the collation to utf8mb4_unicode_ci for more correct text sorting.

Upgrade MySQL Charset utf8 to utf8mb4:

Modify my.conf default setting
New database default charset and collation
Verify existed database structure and data upgrading

Cautions:

Use varchar instead of varcher for saving disk space
Index length field should be limited to 191 but not 255 chars
Alter char-related fields' length by 4/3 to prevent data trucation after upgrade

沒有留言:

張貼留言