当前位置:网站首页>MySQL encoding problem
MySQL encoding problem
2022-04-22 04:55:00 【Liang Yunliang】
Command line operations sql The code problem
mysql> INSERT INTO t_stu VALUES(1,' Zhang San ',' male ');
ERROR 1366 (HY000): Incorrect string value: '\xD5\xC5\xC8\xFD' for column 'sname' at row 1
modify my.ini The configuration file
In path :C:\ProgramData\MySQL\MySQL Server 5.7\my.ini find my.ini file
Modify the content 1:
find [mysql] command , In about 63 Row or so , Add... On the next line
default-character-set=utf8
Modify the content 2:
find [mysqld] command , In about 76 Row or so , Add... On the next line
character-set-server=utf8
collation-server=utf8_general_ci
After modification , restart MySQL57 service
Check the code command
show variables like 'character_%';
show variables like 'collation_%';


- If the above configuration is correct
Command line operations sql It's still messy
mysql> INSERT INTO t_stu VALUES(1,' Zhang San ',' male ');
ERROR 1366 (HY000): Incorrect string value: '\xD5\xC5\xC8\xFD' for column 'sname' at row 1
reason : According to the configuration just now , The server thinks your client's character set is utf-8, In fact, the character set of your client is GBK.

See all character sets :SHOW VARIABLES LIKE ‘character_set_%’;

Solution , Set the client character set of the current connection “SET NAMES GBK;”
set names gbk; It's to tell the server , The client uses GBK code , Prevent confusion code .

sometimes , That doesn't solve the problem , for example , some win10 Under the operating system environment , So modify the properties of the command line -》 Options -》 Check use old console , Then restart the computer

版权声明
本文为[Liang Yunliang]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210738413979.html
边栏推荐
- Download of resource accp-s1 boot3 development tool
- Go parsing command line parameter flag package
- How to get the creator and other information of PNG pictures, not just the file size and other information That is, how to obtain the metadata of the picture
- Objectbox usage record
- Chapter I overview of database
- Chapter 3 basic SQL syntax
- Uninstallation, installation and setting of MySQL
- Summary of topic brushing in April 22
- Recently, it was found that Baidu cloud sharing should be set with extraction code, and can not be set to sharing without extraction code This article will teach you how to bypass Baidu to set up shar
- Rookie's counter attack
猜你喜欢

【板栗糖GIS】arcmap—如何将多张影像合并成一张

2022g2 boiler operator certificate examination question bank and online simulation examination

Data segmentation in training set tuning

Iris species prediction -- Introduction to data set

Combined sum leetcode

【Selenium】UnitTest测试框架的基本应用

How to initiate mqtt 100 million connection and 10 million message throughput performance test
![[Chestnut Sugar GIS] SuperMap - How to make hyperlinks for Data](/img/6d/8b46c96d3ec1005481919e5e81ce80.png)
[Chestnut Sugar GIS] SuperMap - How to make hyperlinks for Data

【板栗糖GIS】supermap—如何为数据制造超链接

Logistic regression -- case: cancer classification and prediction
随机推荐
vue项目 npm run build 打包项目时为css、js文件加时间戳版本号,防止浏览器缓存
2022.04.20华为笔试
The simulation generates random numbers and calculates the birthday of each student
Leetcode refers to offer 65 No addition, subtraction, multiplication and division***
Transaction isolation level and mvcc
SSM + double uses redis to realize three logins, and three logins fail to lock for five minutes
在线预览PDF文件功能实现
How to copy the variables in the chrome console as they are, save and download them locally
POJ - 2456 aggressive cows
2021-08-14
Spark 入门程序 : WordCount
On the unsuccessful creation of SQLite database in Android development real machine debugging
Carina 的根基与诞生背景|深入了解 Carina 系列 第一期
Uninstallation, installation and setting of MySQL
Setting method of parameters such as color and linetype of MATLAB curve
PHP prompts unknown modifier when using regular
Linear regression of machine learning
JS Chapter 12
2022 P cylinder filling training questions and answers
How can devices of different brands be compatible and interconnected? Yiwen teaches you to understand