Enable MySQL 5.6 to support Emoji expressions

Source: Internet
Author: User

Enable MySQL 5.6 to support Emoji expressions

Let MySQL support Emoji expressions. We recommend that you use the utf8mb4 character set in advance for MySQL databases involving wireless connections.

MySQL 5.6

1 solution: Convert Mysql encoding from utf8 to utf8mb4.

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

2 Add the my. cnf File

[Mysqld]
Character-set-server = utf8mb4
Collation-server = utf8mb4_unicode_ci
Init_connect = 'set NAMES utf8mb4'

3. Modify the character set of the database and table fields to be added.

Modify the database character set:

Alter database database_name character set = utf8mb4 COLLATE = utf8mb4_unicode_ci;

Modify the character set of a table:

Alter table table_name convert to character set utf8mb4 COLLATE utf8mb4_unicode_ci;

Modify the character set of a field:

Alter table table_name CHANGE column_name VARCHAR (191) character set utf8mb4 COLLATE utf8mb4_unicode_ci;

If you only need to modify the character set of a field

4. If none of the above statements can be modified, query the SQL statement.

Mysql> show variables like '% SQL _mode % ';

+ --------------- + ---------------------------------------------- +

| Variable_name | Value |

+ --------------- + ---------------------------------------------- +

| SQL _mode | STRICT_TRANS_TABLES, NO_ENGINE_SUBSTITUTION |

+ --------------- + ---------------------------------------------- +

1 row in set (0.00 sec)

If the above result is returned, congratulations, you cannot store it.

Set the SQL _mod mode (note that you need to exit the console after modification, or you still cannot see the effect.

This configuration does not take effect when I write my. cnf to restart the server. If you want to ask why please go to the mysql Consulting Group)

Mysql> set global SQL _mode = 'no _ ENGINE_SUBSTITUTION ';

Mysql> show variables like '% SQL _mode % ';

+ --------------- + ------------------------ +

| Variable_name | Value |

+ --------------- + ------------------------ +

| SQL _mode | NO_ENGINE_SUBSTITUTION |

+ --------------- + ------------------------ +

1 row in set (0.00 sec)

6. After completing these steps, let MySQL support Emoji expressions.

This article permanently updates the link address:

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.