当前位置:网站首页>Solve the problem that MySQL cannot insert Chinese data
Solve the problem that MySQL cannot insert Chinese data
2022-08-01 17:43:00 【Wei Wei Qin Qin】
目录
1️⃣When creating a database, set the character set toutf8
我们使用MySQLMay encounter the situation of adding Chinese error,如下.
报错:illegal character value 放入 ‘name’ Why can't I deposit in Chinese??
原因:
for the current database 来说,Internal storage of Chinese is required to specify the corresponding Chinese encoding method!
The database default character set,是“拉丁文”,不能存中文.
我们在控制台输入,The following line of command,查看数据库字符集.
show variables like '%char%';
我们看 character_set_database This line corresponds to Value的是 latinl,而 latinl 是拉丁文,是不支持中文的.
Now we know why the database cannot store Chinese,So what should I do to make the database insert Chinese??我们接着往下看
具体解决方法:
I mainly introduce two methods,一种简单的,一个比较复杂,but it is essentially modifying 数据库 字符编码
1️⃣When creating a database, set the character set toutf8
We set to support Chinese character set when we created the databaseutf8,如下
create database 数据库名 character set utf8;
设置完后,We can change the database to insert Chinese.
When we look at the database again,We will find that we set the database character set to change,but when we use other database,Its character set is still latinl.
这种方法,Simple but requires manual setup every time,Is there a way to do it once and for all.
Let's look at method two.
2️⃣修改数据库配置文件(比较麻烦)
我们可以修改MySQL的配置文件,His character is modified toutf8,This way you don't have to manually set up the database again..
什么是配置文件:
很多程序,Internal support for a variety of“模式”,The current program can be adjusted,let him apply that pattern.
因此就可以借助“开关”来切换模式!Software switches usually use a“图形化界面”,但是对于 MySQL Special software such as programmers generally does not have a corresponding graphical interface to indicate the switch..Only through a special file,to save these switches.这个文件就是 “配置文件”.
So if the programmer wants to adjust these switches,to manually modify this file.
1、找到MySQL的配置文件
The configuration file path is different on each computer,我们可以‘服务’to find its path to
然后在服务中,找到MySQL,find executable path in general,复制下来.
大家可以像我一样,Copy the path and put it in the drawing for easy viewing.如下图,画红线的就是MySQL配置文件路径,Then we look for the configuration file according to the path
在查找过程中 You can't find it ProgramData 文件,The file is hidden,When we click on Show Hidden Items, it will appear.
2、修改文件
找到 后缀为 .ini 文件后,We can open it in Notepad for editing.
注意:
Everyone before editing,一定要先备份!!!
Such files are very critical,Once corrected,mysql 就启动不了了!!
如何备份:We directly select the file,Assign and paste.
First find in the file[mysql],add below default-character-set=utf8
注意:=两侧不要有空格
然后找到[mysqld],把 In the picture below, the red box is changed to character-set-server=utf8 ,Exit and save after making changes
3、重启MySQL服务器(重要)
MySQLis a client server program,我们要重启MySQL服务器.we find in the serviceMySQL之后,Right click to restart.重启后MySQL显示‘正在运行’,即重启成功!
注意:restart isMySQL服务器,不是MySQL客户端
如果启动失败,Maybe the configuration file is wrong,You can go back and check if there is a spelling error or a lot of spaces.
到这里就配置成功了,We can try to build a library and insert Chinese
The configuration just now,Affects new libraries.old library,still the previous encoding!!! Remember to delete the library,重新建库
边栏推荐
- QT basic functions, signals, slots
- 中信证券是国内十大券商吗?怎么开户安全?
- 棕榈油罐区数字化转型
- 程序员架构修炼之道:如何设计“易理解”的系统架构?
- SQL的索引详细介绍
- QT基础功能,信号、槽
- 【Error】Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘concat’)
- 机器学习快速入门
- How can become a good architect necessary skills: painting for all the people praise the system architecture diagram?What is the secret?Quick to open this article and have a look!.
- 深圳市商务局2022年度中央资金(跨境电子商务企业市场开拓扶持事项)申报指南
猜你喜欢
【报错】Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘concat‘)
QT基础功能,信号、槽
深入分析类加载器
Detailed explanation of the working principle of crystal oscillator
QLineEdit learning and use
How can become a good architect necessary skills: painting for all the people praise the system architecture diagram?What is the secret?Quick to open this article and have a look!.
[供应链·案例篇]石油和天然气行业的数字化转型用例
OpenCV安装、QT、VS配置项目设置
C语言:表达式求值详解
晶振工作原理详解
随机推荐
吴恩达机器学习课后习题——kmeans
C语言理论--笔试面试基础稳固
QT_QDialog 对话框
XAML WPF项目groupBox控件
千万级乘客排队系统重构&压测方案总结篇
棕榈油罐区数字化转型
2022年SQL大厂高频实战面试题(详细解析)
云商店携手快报税,解锁财务服务新体验!
B005 – 基于STC8的单片机智能路灯控制系统
LeaRun.net快速开发动态表单
Unity ui点击事件只响应最上层ui的方式
关于单应性矩阵的若干思考
一加OnePlus 10RT出现在Geekbench上 产品发布似乎也已临近
助推科技强国高质量发展《科创超级训练营》系列活动正式拉开帷幕
QPalette调色板、框架色彩填充
【二叉树】奇偶树
缓存一致性MESI与内存屏障
B011 - 基于51的多功能指纹智能锁
QPalette palette, frame color fill
银行案例|Zabbix跨版本升级指南,4.2-6.0不香吗?