当前位置:网站首页>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持久化参考博文
边栏推荐
- LinkList
- 详解sizeof、strlen、指针和数组等组合题
- Why can void * be a general pointer
- Maxcompute string splitting function -split_ PART
- Clion toolchains are not configured configure disable profile problem solving
- Golang time format sorting
- Mall management system of database application technology course design
- Easy touch plug-in
- One dimensional array two dimensional array (sort Max insert sort)
- About Wireshark's unsuccessful installation of npcap
猜你喜欢

Ue5 opencv plug-in use

图像处理8-CNN图像分类
![[set theory] order relation (hastu example | divisive relation hastu | inclusive relation hastu | refinement relation hastu)](/img/de/1c75b5e7ed79aca47462de365428a7.jpg)
[set theory] order relation (hastu example | divisive relation hastu | inclusive relation hastu | refinement relation hastu)

Multi traveling salesman problem -- overview of formula and solution process
![[cocos creator] Click the button to switch the interface](/img/b8/f0fd54a2a197cbfd788990e2806b52.png)
[cocos creator] Click the button to switch the interface

Transfinite hacker cognition

超限黑客认知

freetype库的移植

the installer has encountered an unexpected error installing this package

Un système de gestion de centre commercial pour la conception de cours de technologie d'application de base de données
随机推荐
One dimensional array two dimensional array (sort Max insert sort)
Delete the last character of the string in golang
Conversion between string and int types in golang
How to establish rectangular coordinate system in space
[global product discovery 2] the first pure cloud augmented reality (AR) platform - Israel
Cesium service deployment, and import and display local 3dfiles data
璞华PLM为全场景产品生命周期管理赋能,助力产品主线的企业数字化转型
Classes and objects
Huawei interview summary during the epidemic
Scite change background color
I want to do large screen data visualization application feature analysis
數據庫應用技術課程設計之商城管理系統
The general trend of data news releases the power of visual reporting ----- essays after reading
Golang string segmentation, substitution and interception
Editor Extensions
freetype库的移植
Idea dereference display effect
Yolo series --- xml2txt script
An intern's journey to cnosdb
Map的实现类的顺序性