当前位置:网站首页>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 .
边栏推荐
- Port occupation troubleshooting
- Interview question: general layout and wiring principles of high-speed PCB
- Unity shader beginner's Essentials (I) -- basic lighting notes
- Expérience de port série - simple réception et réception de données
- 实现自定义内存分配器
- E-commerce campaign Guide
- Calf problem
- PMP Exam details after the release of the new exam outline
- Markdown editor Use of MD plug-in
- The essence of high availability
猜你喜欢

LeetCode 715. Range module

How long does the PMP usually need to prepare for the exam in advance?

Calf problem

JVM 内存结构 详细学习笔记(一)

C language pointer (special article)

What are the conditions for applying for NPDP?

JVM 垃圾回收 详细学习笔记(二)

PMP examination experience sharing

C language for calculating the product of two matrices

How to pass the PMP Exam in a short time?
随机推荐
JVM garbage collection detailed learning notes (II)
Upgrade Alibaba cloud RDS (relational database service) instance to com mysql. jdbc. exceptions. Troubleshooting of jdbc4.communicationsexception
Locust performance test 2 (interface request)
个人力扣题目分类记录
Simulation volume leetcode [general] 1706 Where does the ball meet
How long does the PMP usually need to prepare for the exam in advance?
使用Typora编辑markdown上传CSDN时图片大小调整麻烦问题
Un salaire annuel de 50 W Ali P8 vous montrera comment passer du test
Systick tick timer
STM32串口寄存器库函数配置方法
Newly found yii2 excel processing plug-in
模拟卷Leetcode【普通】1567. 乘积为正数的最长子数组长度
如何统计项目代码行数
Several stages of PMP preparation study
STM32 clock system
Led analog and digital dimming
OpenGL 3D graphics rendering
Simulation volume leetcode [general] 1567 Length of the longest subarray whose product is a positive number
Personal deduction topic classification record
Summary of PMP learning materials