当前位置:网站首页>mysql 解决不支持中文的问题
mysql 解决不支持中文的问题
2022-07-25 09:26:00 【scwMason】
前提
环境是在ubuntu下
方法
1.查看一下mysql默认字符集

- character_set_client为客户端编码方式;
- character_set_connection为建立连接使用的编码;
- character_set_database数据库的编码;
- character_set_results结果集的编码;
- character_set_server数据库服务器的编码;
2.修改配置文件
linux系统下,修改MySQL数据库默认编码的步骤为:
- 修改
/etc/mysql/mysql.conf.d/mysqld.cnf文件
xhost + #如果xhost +不能执行,报错:xhost : unable to open display “”
sudo gedit /etc/mysql/mysql.conf.d/mysqld.cnf
- 在 [mysqld ] 下面加入
#我这里更改为utf8mb4是因为存储emoji表情报错。
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
init_connect='SET NAMES utf8mb4'
- 修改mysql.cnf文件
sudo gedit /etc/mysql/conf.d/mysql.cnf- 在[mysql]下方加入
default-character-set = utf8mb4
3.重启mysql
sudo service mysql stop
sudo service mysql start4.查看更改后的编码方式

好了,设置完毕,可以愉快的存储数据了,还能保存emoji表情。
后续
如果是已经存在的表的话,可以先查看一下表支持的字符集
show create table entries2;然后根据情况修改表的字符
alter table table_name convert to character set utf8mb4;
边栏推荐
- Pnpm Brief
- oracle 解析同名xml 问题
- Use and principle of rest
- 【近万字干货】别让你的简历配不上你的才华——手把手教你制作最适合你的简历
- yarn速查手册
- OSPF协议的配置(以华为eNSP为例)
- The economic basis of a hardware siege lion
- Record some JS tool functions
- An ASP code that can return to the previous page and automatically refresh the page
- 用ESP32+TM1638实验NTP网络校时闹钟的ARDUINO代码
猜你喜欢
随机推荐
基础背包问题
pnpm简述
message from server: “Host ‘xxx.xxx.xxx.xxx‘ is not allowed to connect to this MySQL server“
Probability theory and mathematical statistics 4 continuous random variables and probability distributions (Part 1)
NPM details
@Import,Conditional和@ImportResourse注解
CCF 201604-2 Tetris
Configuring ROS development environment with vscode: Causes and solutions to the problem of ineffective code modification
UE4 LoadingScreen动态加载启动动画
Redis使用场景
字符串切片的用法
ThreadLocal&Fork/Join
Mlx90640 infrared thermal imager temperature measurement module development notes (I)
Nodejs初体验
Data viewing and parameter modification of multi-channel vibrating wire, temperature and analog sensing signal acquisition instrument
小程序H5获取手机号方案
Probability theory and mathematical statistics 3 discrete random variables and probability distributions (Part 2)
VLAN的配置及其应用(以华为eNSP为例)
Internal structure of SOC chip
canal实现mysql数据同步
![腾讯云之错误[100007] this env is not enable anonymous login](/img/a2/a209a0d94e3fbf607242c28d87e2dd.png)


![严重 [main] org.apache.catalina.util.LifecycleBase.handleSubClassException 初始化组件](/img/39/6f6760e80acec0b02028ea2ed1a5b1.png)





