当前位置:网站首页>Docker runs MySQL service
Docker runs MySQL service
2022-07-28 11:55:00 【Virgocloud】
1、 choice mysql edition
Official website :https://hub.docker.com/search?q=mysql&type=image
2、 Will mirror the file pull Come down
notes : The latest version is pulled by default without specifying the version number
docker pull mysql
3、 start-up mysql service
a、 Basic startup
docker run -e MYSQL_ROOT_PASSWORD=root mysql:5.7.32
Tips:-e MYSQL_ROOT_PASSWORD=root ( It means that you will mysql The password is set to root)
mysql:5.7.32( Said the use of mysql5.7.32 edition )
b、 Start a mysql service , Background operation , Appoint root User password , Specify container name , Specify the service port
docker run -d --name mysql01 -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root mysql:5.7.32
[[email protected] ~]# docker run -d --name mysql01 -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root mysql:5.7.327c5d8c5c2d8e90984c3ac0029de3f39d9ba3fb886a3be3e3fd0640b68d348826
[[email protected]ost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7c5d8c5c2d8e mysql:5.7.32 "docker-entrypoint.s…" 4 seconds ago Up 3 seconds 0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp mysql01
c、 Start a mysql Background operation , Appoint root User password , Specify container name , Use data volumes to persist to the host , Name
Tips: stay docker You can find it on the official website mysql Data is stored in by default /var/lib/mysql Under the path
[[email protected] ~]# docker volume ls
DRIVER VOLUME NAME
local 0c77d0f737012800333dde2bdb5f84674903738abc090e532561a1f5c2456203
local 7f0747d3a03bc867ae9338da399322f6c979fb4b54225c3ff16cba037a22cc6a
local 406ce50d2669e066948b10c7b37a4d77b69369fbbeaca4283720494cb472fe43
local dcb2a5cd7c2da4e3bbf9bab6327bbb5e7eb501628a9391f12e1f41276bb9ad81
[[email protected] ~]# docker run -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root --name mysql -v mysqldata:/var/lib/mysql mysql:5.7.32
a5c43b2aa6a3e698553a7db0b68ae74d7290359e945671112b24bfff8cf97bd4
[[email protected] ~]# docker volume ls
DRIVER VOLUME NAME
local 0c77d0f737012800333dde2bdb5f84674903738abc090e532561a1f5c2456203
local 7f0747d3a03bc867ae9338da399322f6c979fb4b54225c3ff16cba037a22cc6a
local 406ce50d2669e066948b10c7b37a4d77b69369fbbeaca4283720494cb472fe43
local dcb2a5cd7c2da4e3bbf9bab6327bbb5e7eb501628a9391f12e1f41276bb9ad81
local mysqldata
[[email protected] ~]# docker volume inspect mysqldata
[
{
"CreatedAt": "2021-08-30T17:27:50+08:00",
"Driver": "local",
"Labels": null,
"Mountpoint": "/var/lib/docker/volumes/mysqldata/_data", (mysql The data is attached to this path )
"Name": "mysqldata",
"Options": null,
"Scope": "local"
}
]
[[email protected] ~]# cd /var/lib/docker/volumes/mysqldata/_data
[[email protected] _data]# ls ( thus it can be seen mysql Data has been successfully synchronized to the host )
auto.cnf client-cert.pem ibdata1 ibtmp1 private_key.pem server-key.pem
ca-key.pem client-key.pem ib_logfile0 mysql public_key.pem sys
ca.pem ib_buffer_pool ib_logfile1 performance_schema server-cert.pem


d、 Start a mysql Background operation , Appoint root User password , Specify container name , Use data volumes to persist to the host , Name , Mount the configuration file to the host
docker run -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root --name mysql -v mysqldata:/var/lib/mysql -v mysqlconfig:/etc/mysql mysql:5.7.32
Tips: It can be seen on the official website mysql The configuration file is stored in /etc/mysql Next
[email protected]:/etc/mysql# ls
conf.d my.cnf my.cnf.fallback mysql.cnf mysql.conf.d
[email protected]:/etc/mysql#
边栏推荐
- [applet] how to notify users of wechat applet version update?
- P5472 [noi2019] douzhudi (expectation, Mathematics)
- Autumn recruit offer harvesters, and take the offers of major manufacturers at will
- Database advanced learning notes cursor
- How async await implements concurrency
- mysql(8.0.16版)命令及说明
- Guys, ask me, this can't be checkpoint, because there is a JDBC task whose task status is finished,
- Cvpr2020 best paper: unsupervised learning of symmetric deformable 3D objects
- Will PFP be the future of digital collections?
- Object to object mapping -automapper
猜你喜欢

拥抱开源指南

A new mode of one-stop fixed asset management

14. User web layer services (II)
![[geek challenge 2019] babysql-1 | SQL injection](/img/21/b5b4727178a585e610d743e92248f7.png)
[geek challenge 2019] babysql-1 | SQL injection

Unity鼠标带动物体运动的三种方法

移动端人脸风格化技术的应用

LabVIEW AI视觉工具包(非NI Vision)下载与安装教程

一文看懂设备指纹如何防篡改、防劫持

How to effectively implement a rapid and reasonable safety evacuation system in hospitals

Autumn recruit offer harvesters, and take the offers of major manufacturers at will
随机推荐
Go deadlock - when the channel meets mutex
R language uses dplyr package group_ By function and summarize function calculate the mean value of all covariates involved in the analysis based on grouped variables (difference in means of covariate
Understand how to prevent tampering and hijacking of device fingerprints
Today's sleep quality record 74 points
Final modifier attribute
A lock faster than read-write lock. Don't get to know it quickly
R language uses LM function to build regression model with interactive items, and uses: sign (colon) to represent the interaction of variables (colon is pure multiplication, excluding the constituent
Who's the big God help? Let's see how Oracle number type parsing works. Struct{scale=15, Val
Redis installation
How async await implements concurrency
[applet] how to notify users of wechat applet version update?
Advanced database technology learning notes 1 -- Oracle deployment and pl/sql overview
Design a system that supports millions of users
STL の 概念及其应用
boost官网搜索引擎项目详解
【MySQL】Got an error reading communication packets
Shell (I)
R language ggplot2 visualization: use the ggboxplot function of ggpubr package to visualize the box diagram and customize the fill parameter to configure the filling color of the box
[极客大挑战 2019]BabySQL-1|SQL注入
程序的存储态与运行态