docker安装Mysql8.0并挂载外部配置和数据
环境
CentOS Linux release 7.7.1908 (Core)
拉取Mysql8.0 镜像
docker pull mysql:8.0.18
创建挂载目录
mkdir -p /home/app/mysql/conf
mkdir -p /home/app/mysql/data
mkdir -p /home/app/mysql/logs
放入my.cnf
vi /home/app/mysql/conf/my.cnf
把下面配置复制到文件中
# Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# The MySQL Server configuration file.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
[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
# Custom config should go here
!includedir /etc/mysql/conf.d/
创建启动容器
docker run --restart=always -d -v /home/app/mysql/conf.d/my.cnf:/etc/mysql/my.cnf -v /home/app/mysql/logs:/logs -v /home/app/mysql/data/mysql:/var/lib/mysql -p 3306:3306 --name mysql -e MYSQL_ROOT_PASSWORD=123456 mysql:8.0.18
参数解释
--restart=always -> 开机启动容器,容器异常自动重启
-d -> 以守护进程的方式启动容器
-v /home/app/mysql/conf.d/my.cnf:/etc/mysql/my.cnf -> 映射配置文件
-v /home/app/mysql/logs:/logs -> 映射日志
-v /home/app/mysql/data/mysql:/var/lib/mysql -> 映射数据
-p 3306:3306 -> 绑定宿主机端口
--name mysql -> 指定容器名称
-e MYSQL_ROOT_PASSWORD=123456 -> 写入配置root密码
最终结果

docker安装Mysql8.0并挂载外部配置和数据的更多相关文章
- docker安装MySQL8,目录挂载、配置用户名密码、忽略表名大小写、连接数、特殊字符、时区
原文:docker安装MySQL8,目录挂载.配置用户名密码.忽略表名大小写.连接数.特殊字符.时区 一.环境配置 1.系统:centos7.3 2.docker版本:Docker version 1 ...
- 【Docker】:使用docker安装redis,挂载外部配置和数据
普通安装 1.拉取镜像,redis:4.0 docker pull redis:4.0 2.创建redis容器名"redistest1",并开启持久化 docker run -d ...
- 使用Docker安装mysql,挂载外部配置和数据
.挂载外部配置和数据安装 mkdir /opt mkdir /opt/mysql mkdir /opt/mysql/conf.d mkdir /opt/mysql/data/ 创建my.cnf配置文件 ...
- 【Docker】:使用docker安装mysql,挂载外部配置和数据
普通安装 1.下载镜像,mysql 5.7 docker pull mysql:5.7 2.创建mysql容器,并后台启动 docker run -d -p 3306:3306 -e MYSQL_US ...
- docker安装redis 5.0.7并挂载外部配置和数据
环境 CentOS Linux release 7.7.1908 (Core) 拉取redis 5.0.7 镜像 docker pull redis:5.0.7 创建挂载目录 mkdir -p /ho ...
- Docker安装MySQL8.0
环境 CentOS 7.5 Docker 1.13.1 MySQL 8.0.16 安装 拉取镜像 默认拉取最新版本的镜像 $ docker pull mysql 如果要指定版本,使用下面的命令 $ d ...
- Docker 安装mysql8.0
1. 下载Mysql的Docker镜像: $ docker search mysql (搜索mysql镜像) $ docker pull mysql (下载mysql镜像,默认最新版本) 2. 运行镜 ...
- Docker部署Mysql8.0.20并配置主从复制
1. Linux安装Mysql8.0.20并配置主从复制(一主一从,双主双从) Linux安装Mysql8.0.20并配置主从复制(一主一从,双主双从) 2. 前提准备 # 创建主从数据库文件夹 ...
- Linux安装Mysql8.0.20并配置主从复制(一主一从,双主双从)
1. 主从复制解释 将主数据库的增删改查等操作记录到二进制日志文件中,从库接收主库日志文件,根据最后一次更新的起始位置,同步复制到从数据库中,使得主从数据库保持一致. 2. 主从复制的作用 高可用 ...
随机推荐
- CSUOJ1811 Tree Intersection (启发式合并)
Bobo has a tree with n vertices numbered by 1,2,…,n and (n-1) edges. The i-th vertex has color c i, ...
- 从头学pytorch(二) 自动求梯度
PyTorch提供的autograd包能够根据输⼊和前向传播过程⾃动构建计算图,并执⾏反向传播. Tensor Tensor的几个重要属性或方法 .requires_grad 设为true的话,ten ...
- python 2.7编码问题
问题引入 先看下面的代码,代码用utf8编码格式保存. print("中") 仅有一行代码,但是这个代码无论在ubuntu下还是win7下都会报错,错误信息类似是下面的内容: Sy ...
- isensor app kit 之 CF5642V2 OV5642 测试总结
. 总结; 使用官哥的cf5642c-v2时,需要将isensor app kit 上的iic上拉电阻去掉,否则可能导致寄存器初始化不成功,去掉即可,使用柴草电子的模组则不需要.
- 深入学习CSS3-flexbox布局
学习博客:https://css-tricks.com/snippets/css/a-guide-to-flexbox/ 学习博客:http://caibaojian.com/demo/flexbox ...
- CSS预处理器之less和sass
CSS预处理器 1. 基于CSS的另一种语言 2. 通过工具编译成CSS 3. 添加了很多CSS不具备的特性 4. 能提升CSS文件的组织方式 ...
- 【Feign】自定义配置
[Feign]自定义配置 转载: 自定义配置,如果在同一个工程,注意配置不要和@SpringBootApplication或@ComponentSacan放在用一个包下,就是不要被扫描上 packag ...
- 【Element UI】使用问题记录
[Element UI]使用问题记录 转载:https://www.cnblogs.com/yangchongxing/p/10750994.html 下载地址: https://unpkg.com/ ...
- 【CentOS7】修改yum源
[CentOS7]修改yum源 转载:https://www.cnblogs.com/yangchongxing/p/10645944.html 1.备份源 # mv /etc/yum.repos.d ...
- ansible部署nginx
1.配置免密登录 [root@localhost ansible]# vim /etc/ansible/hosts //用来配置目标主机 加入以下内容 [nginx] //目标主机组 192.168. ...