当前位置:网站首页>When inputting an expression in the input box, an error is reported: incorrect string value:'\xf0\x9f... ' for column 'XXX' at row 1
When inputting an expression in the input box, an error is reported: incorrect string value:'\xf0\x9f... ' for column 'XXX' at row 1
2022-07-07 09:10:00 【Stick to this persistence】
One 、 The reason for the error :
This problem , as a result of UTF-8 The code may be 2-4 Bytes .Emoji Expressions or some special characters are 4 Bytes , and Mysql Of utf8 Code the most 3 Bytes , So the data doesn't plug in .
Two 、 Solution :
1. stay mysql Found in the installation directory of my.ini, Make the following changes :
[mysqld]
# Set character set
loose-default-character-set = utf8mb4
[client]
# Set client character set
default-character-set = utf8mb4
Configuration instructions :
[client] Represents the default settings of the client ;
[mysql] Use... On behalf of us mysql Command login mysql Default settings for database ;
[mysqld] Represents the default settings of the database itself ;
2. stay my.ini Add the following settings in :
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
init_connect='SET NAMES utf8mb4'
[mysql]
default-character-set = utf8mb4
Be careful : front 4 The paragraph should be placed in [mysqld] Inside the back position .
3. Modify... In the database mysql The field attribute corresponding to the database is utf8mb4:
ALTER TABLE `a`
MODIFY COLUMN `content` varchar(4000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT ' Content ' AFTER `user_id`;
explain :a: Table name ,content: Enter the field of expression .
If not , Then set the coding format of the database , as follows :
ALTER DATABASE aaa CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci;
explain :aaa: Database name
4. modify java in jdbc.properties Configuration of
jdbc.url=jdbc:mysql://localhost:3306/aaa?useServerPrepStmts=true&rewriteBatchedStatements=true&useUnicode=true&autoReconnect=true
Be careful : Don't have “&characterEncoding=UTF-8”
5. restart mysql service
Return page , Input the expression randomly to test .
边栏推荐
- 【istio简介、架构、组件】
- Summary of PMP learning materials
- 【Istio Network CRD VirtualService、Envoyfilter】
- Systick滴答定时器
- Simple use of Xray
- E-commerce campaign Guide
- 2022-07-06 Unity核心9——3D动画
- JVM garbage collection detailed learning notes (II)
- 【ChaosBlade:根据标签删除POD、Pod 域名访问异常场景、Pod 文件系统 I/O 故障场景】
- Count the number of words in the string c language
猜你喜欢
Systick滴答定时器
Systick tick timer
平台化,强链补链的一个支点
面板显示技术:LCD与OLED
C language for calculating the product of two matrices
MySQL主从延迟的解决方案
[istio introduction, architecture, components]
How to realize sliding operation component in fast application
【Istio Network CRD VirtualService、Envoyfilter】
Output all composite numbers between 6 and 1000
随机推荐
With an annual salary of 50W, Alibaba P8 will come out in person to teach you how to advance from testing
Druid monitoring - Introduction to JMX usage and principle
PMP experience learning and sharing process
Cmake command line use
C language for calculating the product of two matrices
PMP certificate preparation experience sharing
LeetCode 715. Range module
年薪50w阿裏P8親自下場,教你如何從測試進階
【Istio Network CRD VirtualService、Envoyfilter】
硬件大熊原创合集(2022/05更新)
个人力扣题目分类记录
C语言指针(下篇)
OpenGL帧缓冲
Systick滴答定时器
Serial port experiment - simple data sending and receiving
5A summary: seven stages of PMP learning
Full link voltage test of the e-commerce campaign Guide
模拟卷Leetcode【普通】1609. 奇偶树
What is the value of getting a PMP certificate?
C language pointer (exercises)