MySQL utf8mb4 Character Set: supports emoji

Source: Internet
Author: User
Tags check character
(I) Preface

In order to cope with opportunities and challenges of the wireless Internet, and to avoid problems caused by emoji,
We recommend that you use the utf8mb4 character set in advance for MySQL databases involving wireless connection.
This must be a key point of technology selection in the mobile Internet industry.


(Ii) Restrictions

Required> = MySQL 5.5.3 and slave database must also be 5.5. Earlier versions do not support this character set or duplicate error.


(Iii) Brief steps

The following is a configuration step that has not been upgraded to 5.5.3:

① Back up the database
② Upgrade MySQL server to v5.5.3 +

③ Modify the character set of database, table, and column

# For each database: Alter database database_name Character Set = utf8mb4 collate = collate; # for each table: alter table table_name convert to Character Set utf8mb4 collate utf8mb4_unicode_ci; # for each column: alter table table_name change column_name varchar (191) Character Set utf8mb4 collate utf8mb4_unicode_ci; # (Don't blindly copy-paste this! The exact statement depends on the column type, maximum length, and other properties. The above line is just an example for a 'varchar 'column .)
④ Modify my. CNF

[client]default-character-set = utf8mb4[mysql]default-character-set = utf8mb4[mysqld]character-set-client-handshake = FALSEcharacter-set-server = utf8mb4collation-server = utf8mb4_unicode_ciinit_connect='SET NAMES utf8mb4'

⑤ Restart MySQL server and check Character Set

mysql> SHOW VARIABLES WHERE Variable_name LIKE 'character\_set\_%' OR Variable_name LIKE 'collation%';+--------------------------+--------------------+| Variable_name            | Value              |+--------------------------+--------------------+| character_set_client     | utf8mb4            || character_set_connection | utf8mb4            || character_set_database   | utf8mb4            || character_set_filesystem | binary             || character_set_results    | utf8mb4            || character_set_server     | utf8mb4            || character_set_system     | utf8               || collation_connection     | utf8mb4_unicode_ci || collation_database       | utf8mb4_unicode_ci || collation_server         | utf8mb4_unicode_ci |+--------------------------+--------------------+ rows in set (0.00 sec)

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.