当前位置:网站首页>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

边栏推荐
- 关于企业中台规划和 IT 架构微服务转型
- Privacy sandbox is finally coming
- docker 部署mysql8.0
- 解决方案:可以ping别人,但是别人不能ping我
- AI training speed breaks Moore's law; Song shuran's team won the RSS 2022 Best Paper Award
- Reading notes series "modern methods of C language programming" -- Chapter 2
- GAMES202作业0-环境搭建过程&解决遇到的问题
- R language ggplot2 visualization: visualize the line graph and add customized Y-axis label information to the line graph using the labels function
- Li Kou daily question - Day 32 -1232 Dotted line
- 数据库基础:select基本查询语句
猜你喜欢

Leetcode203 remove linked list elements

Lumiprobe lumizol RNA extraction reagent solution

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

Technology implementation and Architecture Practice

How to find the optimal learning rate

1、《创建您自己的NFT集合并发布一个Web3应用程序来展示它们》什么是NFT

Navicat Premium 15 永久破解和2021版本最新IDEA破解(亲测有效)

磁盘的基本知识和基本命令

Solution: you can ping others, but others can't ping me

Leetcode-128 longest continuous sequence
随机推荐
AppGallery Connect场景化开发实战—图片存储分享
R language epidisplay package ordinal or. The display function obtains the summary statistical information of the ordered logistic regression model (the odds ratio and its confidence interval correspo
LiveData postValue会“丢”数据
摄像头的MIPI接口、DVP接口和CSI接口[通俗易懂]
Basic knowledge and commands of disk
R语言epiDisplay包ordinal.or.display函数获取有序logistic回归模型的汇总统计信息(变量对应的优势比及其置信区间、以及假设检验的p值)、write.csv函数保存csv
Reading notes series "modern methods of C language programming" -- Chapter 2
Leetcode-160相交链表
Principal component calculation weight
洞态在某互联⽹⾦融科技企业的最佳落地实践
字节跳动数据平台技术揭秘:基于 ClickHouse 的复杂查询实现与优化
Evaluation of 6 red, yellow and black list cameras: who is the safest? Who has good picture quality? From now on, let you no longer step on thunder
创建您自己的NFT集合并发布一个Web3应用程序来展示它们(介绍)
Introduction to easyclick database
Database foundation: select basic query statement
斯坦福、Salesforce|MaskViT:蒙面视觉预训练用于视频预测
毕业季 | 华为专家亲授面试秘诀:如何拿到大厂高薪offer?
R language ggplot2 visualization: gganimate package transition_ Time function to create dynamic scatter animation (GIF), shadow_ The wake function configures the gradient falloff tailing effect of the
毕业总结
How to find the optimal learning rate