MySQL UTF8MB4 Character set: Support emoji emoji

Source: Internet
Author: User

I solved the problem with his method, the pro-test is available, do not use Navicat for MySQL to query the code,
Enter MySQL in the server with the root command and show variables like ' char% '; the encoding of the command query is the most accurate.

㈠ Preface

In order to deal with the opportunities and challenges of wireless Internet, avoid the problems caused by emoji emoticons,

The UTF8MB4 character set is recommended in advance for MySQL database recommendations involving wireless related

This has to be the key to a technology selection of the mobile internet industry

㈡ restrictions

Requires >= MySQL 5.5.3 version, from the library must be 5.5, the lower version does not support this character set, copy error

㈢ Brief steps

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

① backing up the database

② upgrading MySQL Server to v5.5.3+

③ Modifying the database, table, and column character sets

For each database:alter database database_name CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;# for each table:alter Table table_name CONVERT to CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;# for each column:alter table table_name CHA NGE column_name 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 was just an example for a ' VARCHAR ' column.)

④ modifying MY.CNF

[Client]
Default-character-set = Utf8mb4

[MySQL]
Default-character-set = Utf8mb4

[Mysqld]
Character-set-client-handshake = FALSE
Character-set-server = Utf8mb4
Collation-server = Utf8mb4_unicode_ci
init_connect= ' SET NAMES utf8mb4 '

⑤ restarting MySQL Server, checking the 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)

Http://www.linuxidc.com/Linux/2013-05/84360.htm

MySQL UTF8MB4 Character set: Support emoji emoji

Related Article

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.