当前位置:网站首页>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;
边栏推荐
猜你喜欢

小程序分享功能

Terminal definition and wiring of bsp3 power monitor (power monitor)
![[deployment of deep learning model] deploy the deep learning model using tensorflow serving + tornado](/img/62/78abf16bb6c66726c6e394c9fb4f81.png)
[deployment of deep learning model] deploy the deep learning model using tensorflow serving + tornado

Introduction to armv8 general timer

Debug篇快捷键入门

Qt 6.2的下载和安装

See how a junior student of double non-2 (0 Internship) can get an offer from Alibaba and Tencent

JDBC总结
![[machine translation] scones -- machine translation with multi tag tasks](/img/72/d3e46a820796a48b458cd2d0a18f8f.png)
[machine translation] scones -- machine translation with multi tag tasks

Mlx90640 infrared thermal imager temperature measurement module development notes (V)
随机推荐
framework打包合并脚本
Mlx90640 infrared thermal imager temperature measurement module development notes (4)
史上最全面的UE4 文件操作,打开,读、写,增、删、改、查
ES6 detailed explanation
js数字千位分割的常用方法
动态规划,购物单问题
Introduction to low power consumption and UPF
cookie and session
Redux使用和剖析
Yarn quick reference manual
Arm preliminaries
Introduction to armv8 general timer
[machine translation] scones -- machine translation with multi tag tasks
message from server: “Host ‘xxx.xxx.xxx.xxx‘ is not allowed to connect to this MySQL server“
Subtotal of rospy odometry sinkhole
VCs common commands
Leetcode 560 前缀和+哈希表
The first week of the fifth stage
mysql历史数据补充新数据
ESP32连接阿里云MQTT物联网平台