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

Analysis of the solution to the problem that MySQL can't store Emoji facial expressions

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

This paper gives an example to illustrate the solution to the problem that MySQL can not store Emoji expressions. Share with you for your reference, the details are as follows:

An error was reported when inserting data:

1366-Incorrect string value:'\ xF0\ x9F\ x98\ x81 'for column' job' at row 23

Solution:

1. Modify the configuration file my.ini [D:\ Program Files\ MySQL\ MySQL Server 5.5]:

[mysql] default-character-set=utf8mb4 [mysqld] character-set-server=utf8mb4

2. Restart the mysql service

3. Modify the encoding method of a table or a field in the table:

First check the encoding method of the database:

Show variables like'% char%'

Modify the encoding of the entire table:

Alter table user convert to character set utf8mb4 collate utf8mb4_bin

Modify the encoding of a field:

The copy code is as follows:-- specify the encoding of a single field

ALTER TABLE user MODIFY COLUMN nick varchar (255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'nickname'

More readers who are interested in MySQL-related content can check out this site topic: "MySQL stored procedure skills Collection", "MySQL Common function Summary", "MySQL Log Operation skills Collection", "MySQL transaction Operation skills Summary" and "MySQL Database Lock related skills Summary".

It is hoped that what is described in this article will be helpful to everyone's MySQL database design.

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

Database

Wechat

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

12
Report