当前位置:网站首页>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 .
边栏推荐
- 5A summary: seven stages of PMP learning
- Common operating commands of Linux
- Port multiplexing and re imaging
- PMP Exam Preparation experience, seek common ground while reserving differences, and successfully pass the exam
- Druid monitoring - Introduction to JMX usage and principle
- MySQL master-slave delay solution
- Three updates to build applications for different types of devices | 2022 i/o key review
- Simulation volume leetcode [general] 1706 Where does the ball meet
- Unityshader introduction essentials personal summary -- Basic chapter (I)
- MySQL主从延迟的解决方案
猜你喜欢

Three updates to build applications for different types of devices | 2022 i/o key review

Upgrade Alibaba cloud RDS (relational database service) instance to com mysql. jdbc. exceptions. Troubleshooting of jdbc4.communicationsexception

What are the conditions for applying for NPDP?

STM32的时钟系统

Interview question: general layout and wiring principles of high-speed PCB

为不同类型设备构建应用的三大更新 | 2022 I/O 重点回顾

C语言指针(中篇)

E-commerce campaign Guide

Systick tick timer

UnityShader入门精要个人总结--基础篇(一)
随机推荐
How to realize sliding operation component in fast application
What is the use of PMP certificate?
模拟卷Leetcode【普通】1609. 奇偶树
C language pointer (Part 2)
Enterprise manager cannot connect to the database instance
Register address name mapping
年薪50w阿裏P8親自下場,教你如何從測試進階
PMP examination experience sharing
UnityShader入门精要个人总结--基础篇(一)
H3C VXLAN配置
个人力扣题目分类记录
2022-06-30 Unity核心8——模型导入
实现自定义内存分配器
ChaosBlade:混沌工程简介(一)
Esp32-ulp coprocessor low power mode RTC GPIO interrupt wake up
Platformization, a fulcrum of strong chain complementing chain
STM32的时钟系统
Screen automatically generates database documents
PMP experience learning and sharing process
PPT模板、素材下载网站(纯干货,建议收藏)