当前位置:网站首页>Docker install and start MySQL service
Docker install and start MySQL service
2022-07-03 03:27:00 【Water W】
Catalog
1.docker install mysql
Premise : Make sure your server is installed docker
(1) Enter the command , see docker,
docker info
or
docker version
(2) And then we go into docker hub Officials go to download what they want mysql Mirror image Docker Hub
Search for mysql,
(3) find office edition ,
Click to enter , You can see docker install mysql The order is :
docker pull mysql
(4) On the server linux Run this command in , install mysql,
docker pull mysql
(5) Run the following command to detect mysql Download successful or not ,
docker images
(6) Run the following command to start mysql service , After successful startup, a container is returned ID.
docker run --name mysql-ytz -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 -v /root/data:/var/lib/mysql mysql:latest
explain :
1:--name mysql-ytz: The name of the container after it is started :( Custom naming ) If not set , The system will automatically set a .
-d Start the service on behalf of the background .
2:-p 3306( This is a liunx Port number , The host machine , If we want remote service , The access port is this port ):3306(docker The port of the container , Each container is independent , It can be understood as a system at the operating system level ), To access this port is to remotely access the port of the host first , Then map to docker Port access of the container mysql.
3:-e MYSQL_ROOT_PASSWORD=123456 This is to say mysql Startup password required for startup , The default account number is root , The password is set above :123456
4: -v /root/data:/var/lib/mysql /root/data/: This is the data storage path of the host ( You can also customize it ),
5: /var/lib/mysql: This is a mysql Where containers store data . Also for synchronizing data , prevent , After the container is deleted , The data doesn't exist .
6: Version number
2. Connect to database
(7) Finally, connect to the database , I was in navicat Connected in ,
- Connection name : I started it myself
- host :ip Address , Local localhost
- port : The port number is the same as that in the previous command , The general default is 3306
docker run --name mysql-ytz -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 -v /root/data:/var/lib/mysql mysql:latest
- user name :root
- password : Use the password set by the previous command
docker run --name mysql-ytz -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 -v /root/data:/var/lib/mysql mysql:latest
After the connection , The database appears ,
OK, This means that the connection is connected .
边栏推荐
猜你喜欢
On the adjacency matrix and adjacency table of graph storage
渤、黄海的潮汐特征
Pytorch配置
Positioning (relative positioning, absolute positioning, fixed positioning, Z-index) 2022-2-11
PAT乙级“1104 天长地久”DFS优化思路
Introduction to mongodb
Hi3536C V100R001C02SPC040 交叉编译器安装
Hi3536c v100r001c02spc040 cross compiler installation
Pytorch multi card distributed training distributeddataparallel usage
Stop using system Currenttimemillis() takes too long to count. It's too low. Stopwatch is easy to use!
随机推荐
Why does thread crash not cause JVM crash
Captura下载安装及在Captura配置FFmpeg
Pytorch multi card distributed training distributeddataparallel usage
Unity3d RPG implementation (medium)
Pytoch configuration
Pytorch轻量级可视化工具wandb(local)
Bigvision code
[mathematical logic] predicate logic (individual word | individual domain | predicate | full name quantifier | existence quantifier | predicate formula | exercise)
[leetcode question brushing day 34] 540 Unique element in array, 384 Disrupt array, 202 Happy number, 149 Maximum number of points on a line
About HTTP cache control
QT based tensorrt accelerated yolov5
解决高并发下System.currentTimeMillis卡顿
Tidal characteristics of the Bohai Sea and the Yellow Sea
Agile certification (professional scrum Master) simulation exercise-2
[AI practice] Application xgboost Xgbregressor builds air quality prediction model (I)
@Accessors annotation function specifies that the prefix follows the hump naming
Pat class B common function Usage Summary
MySql实战45讲【全局锁和表锁】
Anhui University | small target tracking: large-scale data sets and baselines
The difference between static web pages and dynamic web pages & the difference between Web1.0 and Web2.0 & the difference between get and post