当前位置:网站首页>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 .
边栏推荐
- UnityShader入门精要个人总结--基础篇(一)
- How to pass the PMP Exam in a short time?
- OpenGL三维图形绘制
- Enterprise manager cannot connect to the database instance
- Unityshader introduction essentials personal summary -- Basic chapter (I)
- 【ChaosBlade:根据标签删除POD、Pod 域名访问异常场景、Pod 文件系统 I/O 故障场景】
- Unity shader beginner's Essentials (I) -- basic lighting notes
- How to count the number of project code lines
- 2022-07-06 unity core 9 - 3D animation
- 面试题:高速PCB一般布局、布线原则
猜你喜欢
E-commerce campaign Guide
LeetCode 715. Range 模块
STM32串口寄存器库函数配置方法
Storage of data in memory
LED模拟与数字调光
数据在内存中的存储
How to pass the PMP Exam in a short time?
Full link voltage test of the e-commerce campaign Guide
Upgrade Alibaba cloud RDS (relational database service) instance to com mysql. jdbc. exceptions. Troubleshooting of jdbc4.communicationsexception
[istio introduction, architecture, components]
随机推荐
What is the value of getting a PMP certificate?
Newly found yii2 excel processing plug-in
How can I apply for a PMP certificate?
徽商期货公司评级是多少?开户安全吗?我想开户,可以吗?
模拟卷Leetcode【普通】1609. 奇偶树
Register address name mapping
Original collection of hardware bear (updated on May 2022)
[chaosblade: delete pod according to the tag, pod domain name access exception scenario, pod file system i/o failure scenario]
Platformization, a fulcrum of strong chain complementing chain
Locust performance test 4 (custom load Policy)
JVM 内存结构 详细学习笔记(一)
Esp32-ulp coprocessor low power mode RTC GPIO interrupt wake up
Upgrade Alibaba cloud RDS (relational database service) instance to com mysql. jdbc. exceptions. Troubleshooting of jdbc4.communicationsexception
OpenGL帧缓冲
How does the project manager write the weekly summary and weekly plan?
Hard core sharing: a common toolkit for hardware engineers
【ChaosBlade:节点磁盘填充、杀节点上指定进程、挂起节点上指定进程】
Recommended by Alibaba P8, the test coverage tool - Jacobo is very practical
为不同类型设备构建应用的三大更新 | 2022 I/O 重点回顾
PMP Exam Preparation experience systematically improve project management knowledge through learning