当前位置:网站首页>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 .
边栏推荐
- Original collection of hardware bear (updated on June 2022)
- Simulation volume leetcode [general] 1567 Length of the longest subarray whose product is a positive number
- 面试题:高速PCB一般布局、布线原则
- ChaosBlade:混沌工程简介(一)
- What are the conditions for applying for NPDP?
- STM32 serial port register library function configuration method
- Postman interface test (I. installation and use)
- Do you have any certificates with high gold content?
- Three updates to build applications for different types of devices | 2022 i/o key review
- Calculation s=1+12+123+1234+12345 C language
猜你喜欢
Do you have any certificates with high gold content?
串口實驗——簡單數據收發
C语言指针(下篇)
Register address name mapping
C language pointer (exercises)
Reading notes of pyramid principle
STM32 serial port register library function configuration method
2021 year end summary
2022-06-30 Unity核心8——模型导入
Ppt template and material download website (pure dry goods, recommended Collection)
随机推荐
Two schemes of unit test
PMP examination experience sharing
Postman interface test (I. installation and use)
Implement custom memory allocator
[chaosblade: delete pod according to the tag, pod domain name access exception scenario, pod file system i/o failure scenario]
数据在内存中的存储
GoLand set goproxy
LeetCode 736. Lisp 语法解析
C language pointer (special article)
MAC OSX php dyld: Library not loaded: /usr/local/xxxx. dylib
H3C VXLAN配置
Simulation volume leetcode [general] 1557 The minimum number of points that can reach all points
RuntimeError: Calculated padded input size per channel: (1 x 1). Kernel size: (5 x 5). Kernel size c
Platformization, a fulcrum of strong chain complementing chain
The longest ascending subsequence model acwing 1017 Strange thief Kidd's glider
模拟卷Leetcode【普通】1705. 吃苹果的最大数目
OpenGL 3D graphics rendering
OpenGL三维图形绘制
What is the value of getting a PMP certificate?
串口實驗——簡單數據收發