当前位置:网站首页>Docker deploy mysql8.0
Docker deploy mysql8.0
2022-07-01 18:54:00 【51CTO】
The first blog on this platform records , Ha ha ha ha
There is one saying. , These documents are pretty good
Pull it mysql Mirror image
[[email protected] ~]# docker pull mysql:8.0
8.0.27: Pulling from library/mysql
72a69066d2fe: Pulling fs layer
93619dbc5b36: Pulling fs layer
99da31dd6142: Pulling fs layer
626033c43d70: Pull complete
37d5d7efb64e: Pull complete
ac563158d721: Pull complete
d2ba16033dad: Pull complete
688ba7d5c01a: Pull complete
00e060b6d11d: Pull complete
1c04857f594f: Pull complete
4d7cfa90e6ea: Pull complete
e0431212d27d: Pull complete
Digest: sha256:e9027fe4d91c0153429607251656806cc784e91493271037f7738bd5b8e7709
Status: Downloaded newer image for mysql:8.0
docker.io/library/mysql:8.0
Create a mapped mount volume directory
[[email protected] mysql8]# pwd
/opt/mysql8
[[email protected] mysql8]# mkdir conf
[[email protected] mysql8]# mkdir logs
[[email protected] mysql8]# mkdir data

stay conf New directory my.cnf
[mysqld]
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
datadir = /var/lib/mysql
secure-file-priv= NULL
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
character-set-server=utf8
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
# Custom config should go here
!includedir /etc/mysql/conf.d/
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
Run container
docker run --restart=always \
-v /opt/mysql8/conf/my.cnf:/etc/mysql/my.cnf \
-v /opt/mysql8/logs:/logs \
-v /opt/mysql8/data/:/var/lib/mysql \
-p 3310:3306 \
--name mysql8 \
-d mysql:8.0 \
-e MYSQL_ROOT_PASSWORD='123123' \
--privileged=true \
--character-set-server=utf8mb4
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
Argument parsing
Parameters | meaning |
--restart=always | When Docker Restart time , The container starts automatically |
--name | names |
-p 3306:3306 | Port mapping |
-v | Directory mount |
d mysql:8.0 | Specify the running version |
-e MYSQL_ROOT_PASSWORD=‘ password ’ | Set up root User password |
--privileged=true | Endow system root jurisdiction |
--character-set-server=utf8mb4 | Set the character set to utf8mb4 |
Operation steps
( One )、 New file
[[email protected] mysql8]
# pwd
/opt/mysql8
[[email protected] mysql8]
# mkdir conf
[[email protected] mysql8]
# mkdir logs
[[email protected] mysql8]
# mkdir data
- 1.
- 2.
- 3.
- 4.
- 5.
( Two )、 Pull mysql8.0 Mirror image
[[email protected] ~]
# docker pull mysql:8.0
8.0: Pulling from library/mysql
72a69066d2fe: Pulling fs layer
93619dbc5b36: Pulling fs layer
99da31dd6142: Pulling fs layer
626033c43d70: Pull complete
37d5d7efb64e: Pull complete
ac563158d721: Pull complete
d2ba16033dad: Pull complete
688ba7d5c01a: Pull complete
00e060b6d11d: Pull complete
1c04857f594f: Pull complete
4d7cfa90e6ea: Pull complete
e0431212d27d: Pull complete
Digest: sha256:e9027fe4d91c0153429607251656806cc784e91493271037f7738bd5b8e7709
Status: Downloaded newer image
for mysql:8.0
docker.io/library/mysql:8.0
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
( 3、 ... and )、 stay conf New directory my.cnf
[mysqld]
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
datadir = /var/lib/mysql
secure-file-priv= NULL
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
character-set-server=utf8
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
# Custom config should go here
!includedir /etc/mysql/conf.d/
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
( Four )、 stay conf New directory my.cnf
docker run --restart=always -d \
-v /opt/mysql8/conf/my.cnf:/etc/mysql/my.cnf \
-v /opt/mysql8/logs:/logs \
-v /opt/mysql8/data:/var/lib/mysql \
-p 3310:3306 \
--name mysql8 \
-e MYSQL_ROOT_PASSWORD='123123' \
--privileged=true --restart unless-stopped mysql:8.0 \
--character-set-server=utf8mb4
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
( 5、 ... and )、 verification mysql edition
Get the container name
[[email protected] ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8082f1 mysql:8.0 " t.s…" ago hours 33060/tcp 06>3306/tcp mysql8
- 1.
- 2.
- 3.

Go inside the container and see mysql edition

Input mysql -uroot -p , Enter the deployment password ,8.0.29 This is the latest 8 edition
[email protected]:/# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.29 MySQL Community Server - GPL
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
Change Password
Use select user,plugin from user where user='root'; View encryption method
After the above statement is executed , The server remembers to open the Internet port , Use database software to connect
Use database software to connect

边栏推荐
- R语言使用dplyr包的transmute函数计算dataframe数据中的指定数据列的移动窗口均值、使用ggplot2包可视化移动均值与原始数据的折线图
- R语言使用epiDisplay包的aggregate函数将数值变量基于因子变量拆分为不同的子集,计算每个子集的汇总统计信息
- About enterprise middle office planning and it architecture microservice transformation
- ACM mm 2022 video understanding challenge video classification track champion autox team technology sharing
- 搭建一個通用監控告警平臺,架構上需要有哪些設計
- Write an open source, convenient and fast database document query and generation tool with WPF
- 太爱速M源码搭建,巅峰小店APP溢价寄卖源码分享
- R language uses the transmute function of dplyr package to calculate the moving window mean value of the specified data column in dataframe data, and uses ggplot2 package to visualize the line graph b
- Three. JS learning - basic operation of camera (learn from)
- The R language cartools package divides the data, the scale function scales the data, the KNN function of the class package constructs the k-nearest neighbor classifier, and the table function calcula
猜你喜欢

透过华为军团看科技之变(六):智慧公路

斯坦福、Salesforce|MaskViT:蒙面视觉预训练用于视频预测

Leetcode203 移除链表元素

A wonderful time to buy and sell stocks

2. Create your own NFT collections and publish a Web3 application to show them start and run your local environment

bean的生命周期核心步骤总结

Vidéos courtes recommandées chaque semaine: méfiez - vous de la confusion entre « phénomène » et « problème »

Leetcode-83 delete duplicate elements in the sorting linked list

解决方案:可以ping别人,但是别人不能ping我

Leetcode-141 circular linked list
随机推荐
Leetcode-141 circular linked list
Relational database management system of easyclick
Lumiprobe biomolecular quantification - qudye Protein Quantification Kit
bean的生命周期核心步骤总结
code
创建您自己的NFT集合并发布一个Web3应用程序来展示它们(介绍)
app发版后的缓存问题
Lumiprobe 生物分子定量丨QuDye 蛋白定量试剂盒
太爱速M源码搭建,巅峰小店APP溢价寄卖源码分享
力扣每日一题-第32天-1232. 缀点成线
摄像头的MIPI接口、DVP接口和CSI接口[通俗易懂]
Golang error handling
Implementation of converting PCM file to WAV
微服务大行其道的今天,Service Mesh是怎样一种存在?
12 data dimensioning processing methods
Leetcode-128 最长连续序列
AI 训练速度突破摩尔定律;宋舒然团队获得RSS 2022最佳论文奖
3、《创建您自己的NFT集合并发布一个Web3应用程序来展示它们》在本地铸造 NFT
Li Kou daily question - Day 32 -589 N × Preorder traversal of tree
11、用户、组和权限(1)