Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Solve two ways of storing emoji facial expressions in Mysql

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Here are two ways to solve the problem of storing emoji expressions in Mysql. If you are interested, let's take a look at this article. I believe it will be helpful to you after reading the two ways to store emoji expressions in Mysql.

For mysql to store emoji emoticons, you need a database version above 5.5.

There are two main ways to solve the problem:

The first way is to modify the encoding of the field.

The second way is to modify the configuration file.

The first way: self-testing is available.

1) modify the encoding type of the corresponding table field

ALTER TABLE table_name MODIFY COLUMN mark varchar (1000) CHARACTER

SET utf8mb4 COLLATE utf8mb4_unicode_ci

DEFAULT NULL COMMENT 'remarks'

Then make the following settings:

SET NAMES utf8mb4

Then convert the clob type to the char type [convert (mark,char)] and insert the fields in the table.

The second way: due to the lack of test environment, so it has not been tested yet

1) stop the mysql database

2) modify my.cnf or mysql.ini

[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'

3) restart the mysql database

4) check the character set and change other character sets

SHOW VARIABLES WHERE Variable_name LIKE 'character\ _ set\ _%' OR Variable_name LIKE 'collation%'

Modify the database character set:

ALTER DATABASE database_name CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci

Modify the character set of the table:

ALTER TABLE table_name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci

Modify the character set of the field:

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

Read the details of the above two ways to store emoji facial expressions in Mysql and see if you have gained anything. If you want to know more about it, you can continue to follow our industry information section.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report