当前位置:网站首页>Mysql容器化(1)Docker安装MySQL
Mysql容器化(1)Docker安装MySQL
2022-07-03 08:19:00 【wangleleb】
1.容器化的MySQL的问题
docker容器其实就是在镜像的基础上添加了一个读写层,在容器被删除的时候,容器所保持的数据状态将会丢失,对于MySQL这样的持久数据存储是灾难性的,那么这时候容器的数据持久化就显得很必要了。
2.如何实现持久化
在上一个博客Docker持久化中已经做了详细的介绍,读者可以参考一下。
3.MySQL的数据源文件
Mysql的数据文件一般默认是存储在/var/lib/myql下,其中的文件夹对应每个数据库
#其中的wordpress文件夹就是我名称wordpress对应的数据库
[email protected]:/var/lib/mysql# cd /var/lib/mysql && ls
auto.cnf client-key.pem ibdata1 private_key.pem sys
ca-key.pem ib_buffer_pool ibtmp1 public_key.pem wordpress
ca.pem ib_logfile0 mysql server-cert.pem
client-cert.pem ib_logfile1 performance_schema server-key.pem
进入数据库
[email protected]:/var/lib/mysql# cd wordpress/ && ls
db.opt wp_options.frm wp_term_relationships.ibd wp_usermeta.frm
wp_commentmeta.frm wp_options.ibd wp_term_taxonomy.frm wp_usermeta.ibd
wp_commentmeta.ibd wp_postmeta.frm wp_term_taxonomy.ibd wp_users.frm
wp_comments.frm wp_postmeta.ibd wp_termmeta.frm wp_users.ibd
wp_comments.ibd wp_posts.frm wp_termmeta.ibd
wp_links.frm wp_posts.ibd wp_terms.frm
wp_links.ibd wp_term_relationships.frm wp_terms.ibd
[email protected]:/var/lib/mysql/wordpress#
其中的.frm文件为表结构文件。
其中的.ibd文件为表数据文件。
4.通过volume实现数据库数据持久化
- 创建mysql数据卷
- 创建mysql配置卷(开启binlog等)
- 创建mysql日志卷(产生mysql日志)
docker volume create mysql-data \
docker volume create mysql-config \
docker volume create mysql-log
docker run -d -p 3306:3306 \
--name mysql \
-v mysql-data:/var/lib/mysql \
-v mysql-config:/etc/mysql/conf.d \
-v mysql-log:/var/log/mysql \
-e MYSQL_ROOT_PASSWORD=131452 \
mysql:5.7
注意:关于Docker持久化参考博文
边栏推荐
- Free use until 2015 -- viz artist multi touch plug-in package
- Base64 and base64url
- [cocos creator] Click the button to switch the interface
- Flex flexible box layout
- P1596 [USACO10OCT]Lake Counting S
- Initial unity
- 十六进制编码简介
- Wechat native applet cloud development learning record 01
- Use of ue5 QRcode plug-in
- Ilruntime learning - start from scratch
猜你喜欢

C language - Introduction - essence Edition - take you into programming (I)
![[set theory] order relation (the relation between elements of partial order set | comparable | strictly less than | covering | Haas diagram)](/img/df/a034032e203e7935dafaf8a71cb6c8.jpg)
[set theory] order relation (the relation between elements of partial order set | comparable | strictly less than | covering | Haas diagram)

Redis的数据结构

How to establish rectangular coordinate system in space

the installer has encountered an unexpected error installing this package
![P1596 [USACO10OCT]Lake Counting S](/img/a7/07a84c93ee476788d9443c0add808b.png)
P1596 [USACO10OCT]Lake Counting S

Get to know unity2 for the first time

方正锐利重磅升级到12.0版本,包装印前处理更加便捷、高效!

Puhua PLM empowers the whole scene product lifecycle management and helps the enterprise digital transformation of the main line of products

Display terrain database on osgearth ball
随机推荐
Unity2019_ Lighting system
[cocos creator] get the resource UUID
JS to implement publish and subscribe
Youyou1 of xlua knapsack system
Golang 中string和int类型相互转换
Editor Extensions
Cesium service deployment, and import and display local 3dfiles data
Open the influence list of "National Meteorological Short Videos (Kwai, Tiktok) in November" in an interactive way“
Multi traveling salesman problem -- overview of formula and solution process
An intern's journey to cnosdb
Golang的range
jupyter远程服务器配置以及服务器开机自启
Classes and objects
Kwai 20200412 recruitment
Are you still watching the weather forecast on TV?
MaxCompute字符串分割函数-SPLIT_PART
【音视频】ijkplayer错误码
C language - Introduction - essence Edition - take you into programming (I)
Image processing 8-cnn image classification
Transplantation of tslib Library