当前位置:网站首页>un7.30:Linux——如何在docker容器中显示MySQL的中文字符?
un7.30:Linux——如何在docker容器中显示MySQL的中文字符?
2022-07-30 17:12:00 【优秀的小爱子】
上一篇博客中,我们已经在docker中成功安装了MySQL,接下来,我就给大家分享一下,如何在docker中使用MySQL,包括在docker容器中显示MySQL的中文字字符。
一、输入指令进入,注意换一下端口号,或者把之前的端口号停掉,命令:docker run -d -p 3309:3309 --privileged=true -v /usr/share/mysql/log:/var/log/mysql -v /usr/share/mysql/data:/var/lib/mysql -v /usr/share/mysql/conf:/etc/mysql/conf.d -e MYSQL_ROOT_PASSWORD=Aa123123. --name m2 mysql

二、查看运行的镜像,命令:docker ps

三、 进入到路径下,命令:cd /usr/share/mysql/conf/

四、新建my.cnf,添加下列内容,
[client]
default_character_set=utf8
[mysqld]
collation_server = utf8_general_ci
character_set_server = utf8
五、输入指令再次查看,我们可以看到和我们刚才添加的内容一模一样,命令:cat my.cnf

六、查看运行容器,命令:docker ps

七、重启查看,命令:docker restart m2

八、登录,命令:mysql -uroot -p

九,输入指令查看字符串类型,命令:SHOW VARIABLES LIKE 'character%';

十、再次建表查看。
1、show databases;

2、create database db01;
![]()
3、use db01;
![]()
4、create table t1(id int,name varchar(20));

5、insert into t2 values(1,'zs');

6、即可看到虚拟机上可以显示中文字符了,命令:select * from t1;

如此,我们便可实现在docker容器中展示中文这一功能了。
边栏推荐
- [Geek Challenge 2020] Roamphp1-Welcome
- Tensorflow模型量化(Quantization)原理及其实现方法
- Go新项目-编译热加载使用和对比,让开发更自由(3)
- ERROR 2003 (HY000) Can‘t connect to MySQL server on ‘localhost3306‘ (10061)解决办法
- The way of life, share with you!
- S7-200SMART中定时器的使用方法和常见注意事项汇总
- leetcode:1488. 避免洪水泛滥【二分 + 贪心】
- 论文阅读之《DeepIlluminance: Contextual IlluminanceEstimation via Deep Neural Networks》
- Chapter 6: Decisive Autumn Moves
- 向量检索基础方法总结
猜你喜欢

Tensorflow模型量化(Quantization)原理及其实现方法

Error EPERM operation not permitted, mkdir ‘Dsoftwarenodejsnode_cache_cacach两种解决办法

LeetCode167:有序数组两数之和

You are a first-class loser, you become a first-class winner

Navisworks切换语言
![[HarekazeCTF2019] Avatar Uploader 1](/img/2c/6dde7b8d34ba0deb334b4283e1e30e.png)
[HarekazeCTF2019] Avatar Uploader 1

HUAWEI CLOUD data governance production line DataArts, let "data 'wisdom' speak"

Security business revenue growth rate exceeds 70% 360 builds digital security leader

Shell implementation based on stm32

论文阅读之《Underwater scene prior inspired deep underwater image and video Enhancement (UWCNN)》
随机推荐
关于内和调试无法查看ntdll内存的问题
C语言向MySQL插入数据
获得抖音商品详情 API
Daily practice------Generate 13-digit bar, Ean-13 code rule: The thirteenth digit is the check code obtained by the calculation of the first twelve digits.
The way of life, share with you!
SQLServer下载与安装
onenote使用
fast shell porting
torch.optim.Adam() function usage
.NET 6.0中使用Identity框架实现JWT身份认证与授权
MySQL 8.0.29 解压版安装教程(亲测有效)
[MRCTF2020]Ezaudit
Login Module Debugging - Getting Started with Software Debugging
[MRCTF2020]Ezaudit
基于模糊PID的液压舵机伺服系统
Gvim order record
Lotus 1.16.0 minimum snapshot export import
Error EPERM operation not permitted, mkdir ‘Dsoftwarenodejsnode_cache_cacach两种解决办法
理解实现搜索二叉树
Chapter 6: Decisive Autumn Moves