当前位置:网站首页>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 .
边栏推荐
- [chaosblade: node disk filling, killing the specified process on the node, suspending the specified process on the node]
- Leetcode刷题记录(数组)组合总和、组合总和 II
- Digital triangle model acwing 1027 Grid access
- C language for calculating the product of two matrices
- Simulation volume leetcode [general] 1609 Parity tree
- Un salaire annuel de 50 W Ali P8 vous montrera comment passer du test
- Port occupation troubleshooting
- Locust performance test 4 (custom load Policy)
- Several common database connection methods
- 面板显示技术:LCD与OLED
猜你喜欢

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

MySQL主从延迟的解决方案

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

Troublesome problem of image resizing when using typora to edit markdown to upload CSDN

Full link voltage test of the e-commerce campaign Guide

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

Selenium mouse sliding operation event

Locust performance test 4 (custom load Policy)

Systick滴答定时器

寄存器地址名映射
随机推荐
systemd
模拟卷Leetcode【普通】1705. 吃苹果的最大数目
Two schemes of unit test
Upgrade Alibaba cloud RDS (relational database service) instance to com mysql. jdbc. exceptions. Troubleshooting of jdbc4.communicationsexception
Port multiplexing and re imaging
Output all composite numbers between 6 and 1000
Several stages of PMP preparation study
How to realize sliding operation component in fast application
JVM garbage collection detailed learning notes (II)
Do you have any certificates with high gold content?
面板显示技术:LCD与OLED
C language pointer (Part 2)
How to use Arthas to view class variable values
C语言指针(中篇)
Problems encountered in the use of go micro
Ppt template and material download website (pure dry goods, recommended Collection)
LeetCode 715. Range 模块
Port occupation troubleshooting
OpenGL三维图形绘制
STM32的时钟系统