Let MySQL support emoji emoticons MySQL 5.6

Source: Internet
Author: User

let MySQL support emoji emoticons, involving wireless-related MySQL database recommendations are in advance with the UTF8MB4 character set.

MySQL version 5.6


1 solution: Convert the MySQL encoding from UTF8 to UTF8MB4.

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


2 my.cnf File added

[Mysqld]
character-set-server = Utf8mb4
collation-server = Utf8mb4_unicode_ci
init_connect= ' SET NAMES utf8mb4 '


3 Modifying the character set to add a library table field

To modify the database character set:

ALTER DATABASE database_name CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;

To modify the character set of a table:

ALTER TABLE table_name CONVERT to CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

To modify the character set of a field:

ALTER TABLE table_name Change column_name column_name VARCHAR (191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

If it's just a field, you just need to modify that field's character set.


4 If you do not modify the above, please query SQL

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 that's the result, congratulations, you can't store it.

Go to set this sql_mod mode (note that the changes here to see after you exit the console or not see the effect, and

And this configuration write my.cnf Restart the server is not effective, 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 done with this, let MySQL support emoji expression


This article is from the "believe it or not you" blog, please be sure to keep this source http://312461613.blog.51cto.com/965442/1718999

Let MySQL support emoji emoticons MySQL 5.6

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.