当前位置:网站首页>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持久化参考博文
边栏推荐
- Abstract classes and interfaces
- Editor Extensions
- 【音视频】ijkplayer错误码
- Conversion between string and int types in golang
- Detailed explanation of all transfer function (activation function) formulas of MATLAB neural network
- C语言-入门-精华版-带你走进编程(一)
- Haproxy+kept cluster setup 02
- [USACO12MAR]Cows in a Skyscraper G(状态压缩dp)
- the installer has encountered an unexpected error installing this package
- Delete the last character of the string in golang
猜你喜欢
璞华PLM为全场景产品生命周期管理赋能,助力产品主线的企业数字化转型
Haproxy+kept cluster setup 02
Solution détaillée de toutes les formules de fonction de transfert (fonction d'activation) du réseau neuronal MATLAB
Image processing 8-cnn image classification
I want to do large screen data visualization application feature analysis
Use of ue5 QRcode plug-in
图像处理8-CNN图像分类
Unity2019_ Natural ambient light_ Sky box
About the problem that the editor and the white screen of the login interface cannot be found after the location of unityhub is changed
P1596 [USACO10OCT]Lake Counting S
随机推荐
Ilruntime learning - start from scratch
数据分析练习题
使用 FileChannel 进行文件的复制拷贝
About Wireshark's unsuccessful installation of npcap
swagger文档配置
ArrayList
L'installateur a été installé avec une erreur inattendue
Get to know unity2 for the first time
P2704 [noi2001] artillery position (shape pressure DP)
Use of ue5 QRcode plug-in
C course design employee information management system
Map的实现类的顺序性
Pulitzer Prize in the field of information graphics - malofiej Award
Golang url的编码和解码
Golang json格式和结构体相互转换
Abstract classes and interfaces
梯度下降法求解BP神经网络的简单Demo
Wechat applet taro learning record
the installer has encountered an unexpected error installing this package
Unity performance optimization