当前位置:网站首页>关于在cmd中MySQL不能插中文数据的原因
关于在cmd中MySQL不能插中文数据的原因
2022-06-28 08:06:00 【庸懒】
下面是本人参考的博客的链接,本文只是当作笔记记载,如果需要看详细过程建议移步原博客哦
https://www.cnblogs.com/1102whw/p/7815466.html
https://www.iteye.com/blog/lwjlaser-1013071
最近在学习数据库,但是用cmd操作的时候碰见一个问题,就是我使用插入语句的时候一直报错,其他语句没有任何问题,而且错误就出在中文数据上。
这是在power shell上运行的结果,很明显是中文的问题,所以我就查了下发现是命令行编码格式的问题,cmd默认是gbk.于是我将cmd的编码格式改成了utf-8,这个方法在我博客有。但是问题并没有解决。
可以看到我的cmd已经换成了utf-8的格式但是使用插入语句的时候依然有问题。正当我百思不得其解的时候我发现了一个大佬的博客,完美的解决了我的问题,最后我会放出地址,这里先做下笔记。
1.查看数据库安装目录下的my.ini文件,查看红框中是否是是utf-8的格式,这里可以看到我的是没有问题的。
2.使用下面的命令查看自己数据库的编码格式
$ show variables like ‘%char%’;
可以看到我这里全部都是utf-8的格式,按理来说应该大功告成,可是我在执行insert语句的时候报了之前的错,原因就是这万恶的cmd!!!虽然我将cmd的编码格式改成了utf-8但是cmd输入的中文还是gbk,所以输入的中文识别不了,我真是日了旺财了。
3.因为cmd输入编码无法更改,所以只能退而求其次将我们的编码格式改成gbk,使用下面的语句就可以了
$ set names gbk;
这里在说一下数据库字符集的东西,其中与服务器端相关:database、server、system(永远无法修改,就是utf-8);与客户端相关:connection、client、results
虽然可以解决问题但是我个人并不推荐,因为gbk只能显示中文,万一要是整个日文韩文呢?所以咱绝不将就,就必须得用utf-8,所以我建议你使用navicat,好用又强大,用了都说好。
边栏推荐
- SOC timer and interrupt configuration
- flex布局
- Is it reliable to open an account by digging money? Is it safe?
- Airflow2.1.1 ultra detailed installation document
- Sentinel mechanism of redis cluster
- Redis cerebral fissure
- MySQL tablespace parsing
- SQL master-slave replication setup
- asp. Net to search products and realize paging function
- HJ21 简单密码
猜你喜欢
2022巴黎时装周儿童单元6.19武汉站圆满落幕
Configuring MySQL multi instance master-slave synchronization for Linux
ROS 笔记(08)— 服务数据的定义与使用
SOC timer and interrupt configuration
Connaissez - vous le protocole TCP (2)?
kubernetes集群命令行工具kubectl
ROS notes (08) - definition and use of service data
Section VI UART of zynq
A single node obtains the lock lock of the order number
抗洪救灾,共克时艰,城联优品捐赠10万元爱心物资驰援英德
随机推荐
asp. Net datalist to display product information and pictures
LeetCode之三步问题
Ambari (IX) --- use expect to realize no interaction in ambri server setup phase (valid for personal test)
Uvcgan: unt vision transformer cycle-consistent Gan for unpropared image-to-image translation
HJ delete the character with the least number of occurrences in the string
Airflow2.1.1 summary of the pits stepped on in actual combat!!
A single node obtains the lock lock of the order number
Trigonometric transformation formula
Study notes 22/1/17
Kubernetes theoretical basis
Porting ucosiii to stm32f429
Host is not allowed to connect to this MySQL server
Prometheus + grafana + MySQL master-slave replication + host monitoring
SOC serial port configuration
Study notes 22/1/18
AI首席架构师8-AICA-高翔 《深入理解和实践飞桨2.0》
Hj21 simple password
MySQL tablespace parsing
At 19:00 on Tuesday evening, the 8th live broadcast of battle code Pioneer - how to participate in openharmony's open source contribution in multiple directions
本周二晚19:00战码先锋第8期直播丨如何多方位参与OpenHarmony开源贡献