当前位置:网站首页>Docker's latest super detailed tutorial - docker creates, runs, and mounts MySQL
Docker's latest super detailed tutorial - docker creates, runs, and mounts MySQL
2022-07-29 07:26:00 【Programming for Hongmeng】
Docker The latest ultra detailed tutorial ——Docker Create run MySQL And mount
Customize MySQL The configuration file mysql-conf
Where the data is stored mysql-data
Docker The latest ultra detailed tutorial ——Docker Create run MySQL And mount
(1) Pull mysql Mirror image
First of all, we need to Docker Get on the mysql Mirror image , Just go first DockerHub Official website pull One down , Here we choose mysql:8.0.29
docker pull mysql:8.0.29MySQL Large image , therefore pull Of It took a long time , Please be patient !

In order not to pull again next time , It can be Backup (save) Go to the local ( Review the orders !)
docker save -o mysql8.0.29.tar mysql:8.0.29notes :-o Is to specify the file path of the output
If you need it next time , You don't have to go DockerHub On pull 了 , Directly from the local load Just fine !
sudo docker load -i mysql8.0.29.tarnotes :-i Indicates the file name to upload
Here are my Local temporal DockerRepository Warehouse !

(2) Create directory
We do not use data volume mount , Here, the directory is directly mounted ( Specify your own directory !)
Containers can not only mount data volumes , You can also mount directly to the host directory . The relationship is as follows :
With data volume mode : Host directory --> Data volume ---> In-container directory ( We I don't know the catalogue Where is the , You need to go to the official website to find )
Direct mount mode : Host directory ---> In-container directory ( We created our own directory , I know ! Easy to modify later 、 maintain )
mkdir /tmp/mysql/data
mkdir /tmp/mysql/confThen we will customize hmy.cnf The configuration file is passed in !

stay DockerHub Official website There are Provide corresponding information about cnf Explanation of the configuration file :

(3) function mysql Containers
docker run \
--name mysqlname \
-e MYSQL_ROOT_PASSWORD=888888 \
-p 3306:3306 \
-v /tmp/mysql/conf/hmy.conf:/etc/mysql/conf.d/hmy.conf \
-v /tmp/mysql/data:/var/lib/mysql \
-d \
mysql:8.0.29The results are as follows :

There are many directories involved , stay DockerHub Its official website It gives a very specific explanation !
Mysql - Official Image | Docker Hub
Customize MySQL The configuration file mysql-conf

Where the data is stored mysql-data

Use docker ps Check it out. :
docker ps
(4) Test database connection
Up there we pass ps Command to see mysql Containers It's already running , But we need to confirm the visit further mysql Does the database OK. We can open it navicat Tools , Do the following !

Successful connection , See if it can be opened

Testing is completed !
边栏推荐
- PAT甲级 1146 拓扑顺序
- Comparison of advantages between can & canfd integrated test analysis software lkmaster and PCA Explorer 6 analysis software
- 使用自定义注解校验list的大小
- 微服务远程调用
- Interface test actual project 03: execute test cases
- Round avatar of user list and follow small blocks
- Spingboot integrates the quartz framework to realize dynamic scheduled tasks (support real-time addition, deletion, modification and query tasks)
- MySQL - multi table query
- Female graduate students do "mind mapping" and quarrel with their boyfriend! Netizen: the "king of infighting" in the quarrel
- Redis Basics
猜你喜欢

Vite3.0 has been released, can you still roll it (list of new features)

Job 7.28 file IO and standard IO

09 bloom filter

MySQL如何把行转换为列?

2022-07-28: what is the output of the following go language code? A:AA; B:AB; C:BA; D:BB。 package main import ( “fmt“ ) func main() { f

WPF interface layout must know basis
Scala higher order (10): exception handling in Scala

Cvpr2021 | multi view stereo matching based on self supervised learning (cvpr2021)

2-unified return class dto object

Some learning and understanding of vintage analysis
随机推荐
logback简介及引入方法
Explanation of suffix automata (SAM) + Luogu p3804 [template] suffix automata (SAM)
力扣(LeetCode)209. 长度最小的子数组(2022.07.28)
树莓派的启动流程
Homebrew brew update 长时间没反应(或卡在 Updating Homebrew...)
BeanUtils.setProperty()
tp6 使用 ProtoBuf
Thinkphp6 realizes database backup
How does MySQL convert rows to columns?
路由中的生命周期钩子 - activated与deactivated
When NPM is installed, it is stuck. There are five solutions
1-后台项目搭建
利用C语言巧妙实现棋类游戏——三子棋
Excel file reading and writing (creation and parsing)
Other basic monitoring items of ZABBIX
JS break and continue and return keywords
Cvpr2021 | multi view stereo matching based on self supervised learning (cvpr2021)
PAT甲级 1146 拓扑顺序
Personal blog system (with source code)
Section 7 - compilation of programs (preprocessing operations) + links