当前位置:网站首页>Inserting Chinese data into the database table reports an error "1366 (HY000): incorrect string value: '\xe5\x90\x95\xe5' for column 'name' at row 1“
Inserting Chinese data into the database table reports an error "1366 (HY000): incorrect string value: '\xe5\x90\x95\xe5' for column 'name' at row 1“
2022-07-19 16:41:00 【Two trees make a forest】
abnormal
adopt insert Of SQL Statement to insert Chinese data into the database table, and an error is reported :
mysql> INSERT INTO tb_user (name, phone, email, profession, age, gender, status, createtime) VALUES (' Lyu3 bu4 ', '17799990000', '[email protected]', ' Software Engineering ', 23, '1', '6', '2001-02-02 00:00:00');
ERROR 1366 (HY000): Incorrect string value: '\xE5\x90\x95\xE5\xB8\x83' for column 'name' at row 1
reason
In fact, there is a problem with the character set of the database , We didn't specify a character set when we created the database , Then the default character set is used , And we ask to use utf8 perhaps gbk It won't be abnormal in Chinese , And what I use here MySQL 5.7 The default character set is latin1, This character set does not support Chinese display .
Use show create database Database name ; View the character set used by the specified database :


solve
So if we want to solve this problem , In fact, you need to modify the character set of the database or database table . It is better to modify the character set of the database , But if it is a database that has been created, its character set cannot be easily modified , Therefore, the default character set is usually specified when creating the database .
The following command is to modify the character set of the table , Let the table insert Chinese content smoothly , But the character set of the database has not changed . The command format is as follows :
# grammar
alter table Table name convert to character set Character set ;
# Example , Modify the database table tb_user The character set of is utf8
alter table tb_user convert to character set utf8;

Insert Chinese content again and you will succeed .

Reference material :
边栏推荐
- JVM performance tuning method
- VS2019 List Control 控件自绘例程继承CListCtrl类 OnNMCustomdraw重绘
- 03.二分、复杂度、动态数组、哈希表和有序表
- Explore Alibaba cloud IOT development board 1-haas 100
- Realization of communication between ROS and stm32
- 【foobar 2000】如何在手机、电脑上播放局域网内另一台电脑上存储的音乐?FTP服务器、UPnP/DLNA协议、构建Music server、创建音乐服务器
- 自定义MVC 框架
- 想自学软件测试?无情嘲讽。
- STM32中断梅开二度(一)
- Handwritten simple promise code comments
猜你喜欢

Build MySQL Cluster with virtual machine CentOS -- one master and many slaves

Zhang Chaoyang runs 33km at night: live chat on physics reveals the cause of "super moon"

Deep learning environment configuration pytoch

Deep learning environment configuration tensorflow2+keras

二手房房价分析与预测(图表绘制避免中文乱码、饼形图、折线图、条形图(柱形图)、enumerate函数、数据清洗(lambda\map)、二手房预测(scikit-learn))
![[vscode output is garbled] solution](/img/58/77f53ed2f85b58c8bd1c2f2b6bb9f1.png)
[vscode output is garbled] solution

张朝阳夜跑33公里:直播聊物理 揭示“超级月亮”成因
![[foundation of deep learning] how to understand the channel in convolutional neural network](/img/07/283c148fd470cdac0c7538f6d1ce50.png)
[foundation of deep learning] how to understand the channel in convolutional neural network

VS2019 MFC Slider Control 控件继承CSliderCtrl类重绘 自绘

dried food! Integrated fair cold start recommendation system
随机推荐
阿里云(OSS)文件上传和删除
用位运算完成大小比较
简单斐波那契(DAY 67)
OS知识点简介(二)
抽象静态方法
使用深度學習制作機器人大腦圖紙
Gesture Recognition Dataset: Jester 数据集解压
论文阅读_医疗NLP_ SMedBERT
The IPO of Aoyang technology was terminated: the annual revenue was 800million, and Su Wei held 67.5% equity
【Unity3D】UGUI之布局组件
记录使用mRemoteNG软件启动后无法进行复制粘贴
VS2019 MFC Slider Control 控件继承CSliderCtrl类重绘 自绘
05.位图和比较器的简单应用
dried food! Integrated fair cold start recommendation system
TCP/IP协议栈Lwip的设计与实现:之四
Gesture recognition dataset: Jester dataset decompression
Nacos注册表是怎么解决读写并发冲突的
使用go json path的demo
熵基科技通过注册:年营收19.55亿 应收账款账面余额2.9亿
JMeter 21 天打卡 day08