Modify the encoding to UTF8MB4 to support emoji emoticons

Source: Internet
Author: User

Environment:

All character sets for project DB have been initialized to Utf-8, as shown in the status command:

Server Characterset:utf8
Db Characterset:utf8
Client Characterset:utf8
Conn. Characterset:utf8

First, modify the corresponding project database level character set:

Mysql> Show CREATE Database yyf;
+----------+--------------------------------------------------------------+
| Database | Create Database |
+----------+--------------------------------------------------------------+
| YYF | CREATE DATABASE ' yyf '/*!40100 DEFAULT CHARACTER SET UTF8 */| |
+----------+--------------------------------------------------------------+
1 row in Set (0.00 sec)

mysql> ALTER DATABASE YYF CHARACTER SET utf8mb4;
Query OK, 1 row Affected (0.00 sec)

Mysql> Show CREATE Database yyf;
+----------+-----------------------------------------------------------------+
| Database | Create Database |
+----------+-----------------------------------------------------------------+
| YYF | CREATE DATABASE ' yyf '/*!40100 DEFAULT CHARACTER SET utf8mb4 */| |
+----------+-----------------------------------------------------------------+
1 row in Set (0.00 sec)

Second, modify the table-level character set:

ALTER TABLE T1 CHARSET=UTF8MB4;

Third, modify the configuration of the Client connection database:

return [
' Class ' = ' yii\db\connection ',
' drivername ' = ' mysql ',
' DSN ' = ' mysql:host=xxxx;port=3306;dbname=yyf; ',
' Username ' = ' xxxx ',
' Password ' = ' xxxx ',
# # # ' charset ' = ' utf8 ',' charset ' = ' utf8mb4 ',
];

Modify the encoding to UTF8MB4 to support emoji emoticons

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.