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

边栏推荐
- 12种数据量纲化处理方式
- Popular science: what does it mean to enter the kernel state?
- R language uses the aggregate function of epidisplay package to divide numerical variables into different subsets based on factor variables, and calculate the summary statistics of each subset
- Lefse analysis
- 实例讲解将Graph Explorer搬上JupyterLab
- Qt中的QFile读写文件操作
- app发版后的缓存问题
- 实现一个Prometheus exporter
- Case study on comprehensive competitiveness of principal components
- Mise en place d'une plate - forme générale de surveillance et d'alarme, quelles sont les conceptions nécessaires dans l'architecture?
猜你喜欢

微服务大行其道的今天,Service Mesh是怎样一种存在?

Leetcode203 remove linked list elements

【快应用】text组件里的文字很多,旁边的div样式会被拉伸如何解决

Technology implementation and Architecture Practice

为什么独立站卖家都开始做社交媒体营销?原来客户转化率能提高这么多!

What if the reliability coefficient is low? How to calculate the reliability coefficient?

Leetcode-83 删除排序链表中重复的元素

Memo - about C # generating barcode

Must see, time series analysis

LeetCode-21合并两个有序链表
随机推荐
ES6 summary "suggestions collection" of array methods find(), findindex()
Leetcode-141环形链表
bean的生命周期核心步骤总结
【快应用】text组件里的文字很多,旁边的div样式会被拉伸如何解决
1380. Lucky number in matrix / 1672 Total assets of the richest customers
实现一个Prometheus exporter
lefse分析
Privacy sandbox is finally coming
js找出数字在数组中下一个相邻的元素
ACM mm 2022 video understanding challenge video classification track champion autox team technology sharing
Leetcode-128 longest continuous sequence
AppGallery Connect场景化开发实战—图片存储分享
Write an open source, convenient and fast database document query and generation tool with WPF
Image acquisition and playback of coaxpress high speed camera based on pxie interface
Create your own NFT collections and publish a Web3 application to show them (Introduction)
毕业总结
数据仓库(四)之ETL开发
《Go题库·16》读写锁底层是怎么实现的
How to operate technology related we media well?
540. Single element in ordered array / 1684 Count the number of consistent strings