当前位置:网站首页>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持久化参考博文
边栏推荐
- Golang 字符串分割,替换和截取
- 十六进制编码简介
- the installer has encountered an unexpected error installing this package
- Solution détaillée de toutes les formules de fonction de transfert (fonction d'activation) du réseau neuronal MATLAB
- Flex flexible box layout
- Golang 中string和int类型相互转换
- 使用 FileChannel 进行文件的复制拷贝
- Student educational administration management system of C # curriculum design
- Multi traveling salesman problem -- overview of formula and solution process
- Scite change background color
猜你喜欢
随机推荐
matlab神經網絡所有傳遞函數(激活函數)公式詳解
Why can void * be a general pointer
Maxcompute string splitting function -split_ PART
Clip Related Script
YOLO系列 --- xml2txt脚本
oracle中的 (+)是什么意思
Conversion between golang JSON format and structure
Golang 字符串分割,替换和截取
Use filechannel to copy files
the installer has encountered an unexpected error installing this package
Lua framwrok framework starts
Idea unreference Display Effect
Pulitzer Prize in the field of information graphics - malofiej Award
P2704 [NOI2001] 炮兵阵地(状压dp)
P1896 [scoi2005] non aggression (shape pressure DP)
What does (+) in Oracle mean
Redis的数据结构
One dimensional array two dimensional array (sort Max insert sort)
oracle 插入单引号
Zohocrm deluge function application time verification



![P1596 [USACO10OCT]Lake Counting S](/img/a7/07a84c93ee476788d9443c0add808b.png)





