Docker安装MySql-挂载外部数据和配置
- CentOS:7
- Docker:1.31.1
- MySql:5.7
sudo docker run --name mysql5. -p : -e MYSQL\_ROOT\_PASSWORD= -d mysql:5.7
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c84a366e3abf mysql:5.7 "docker-entrypoint..." minutes ago Up seconds /tcp, 0.0.0.0:->/tcp mysql5.
[root@localhost ~]# docker exec -it mysql5. /bin/bash
root@c84a366e3abf:/# cat /etc/mysql/my.cnf
# Copyright (c) , 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 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., Franklin St, Fifth Floor, Boston, MA - USA !includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
root@c84a366e3abf:/# cat /etc/mysql/mysql.conf.d/mysqld.cnf
# Copyright (c) , , 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 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., Franklin St, Fifth Floor, Boston, MA - 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
lower_case_table_names=
#log-error = /var/log/mysql/error.log
# By default we only accept connections from localhost
#bind-address = 127.0.0.1
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=
[root@localhost ~]# docker stop mysql5.
[root@localhost ~]# docker rm mysql5.
[root@localhost ~]# cd /opt
[root@localhost ~]# mkdir mysql
[root@localhost ~]# cd mysql
[root@localhost ~]# mkdir data
[root@localhost ~]# mkdir config
[root@localhost ~]# cd config
[root@localhost ~]# touch mysqld.cnf
[mysqld]
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
datadir = /var/lib/mysql
lower_case_table_names=
#log-error = /var/log/mysql/error.log
# By default we only accept connections from localhost
#bind-address = 127.0.0.1
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=
sudo docker run --name mysql5. --restart always --privileged=true -p : -v /opt/mysql/config/mysqld.cnf:/etc/mysql/mysql.conf.d/mysqld.cnf -v /opt/mysql/data:/var/lib/mysql -e MYSQL_USER="fengwei" -e MYSQL_PASSWORD="pwd123" -e MYSQL_ROOT_PASSWORD="rootpwd123" -d mysql:5.7
–restart always:开机启动
–privileged=true:提升容器内权限
-v /opt/mysql/config/mysqld.cnf:/etc/mysql/mysql.conf.d/mysqld.cnf:映射配置文件
-v /opt/mysql/data:/var/lib/mysql:映射数据目录
-e MYSQL_USER=”fengwei”:添加用户fengwei
-e MYSQL_PASSWORD=”pwd123”:设置fengwei的密码伟pwd123
-e MYSQL_ROOT_PASSWORD=”rootpwd123”:设置root的密码伟rootpwd123
Docker安装MySql-挂载外部数据和配置的更多相关文章
- docker安装mysql挂载外部配置和数据目录
从docker hub上可以找到mysql外挂配置和数据目录的一些文档说明 https://hub.docker.com/_/mysql 从该文档中可以了解到,mysql的默认配置为/etc/mysq ...
- Docker安装mysql镜像并进行主从配置
Docker安装mysql镜像并进行主从配置 1.下载需要的mysql版本镜像 docker pull mysql:5.6 2.启动mysql服务实例(基本启动) #启动主mysql docker r ...
- Docker 安装mysql以及外部访问
(1)因为我们的镜像是linux环境下的,我所在的系统是windows系统.首先通过docker客户端切换到linux环境下. (2)使用docker pull mysql/mysql-server ...
- 35.Docker安装Mysql挂载Host Volume
连个文件系统有块区域Area,我们要做的是把两个Area做文件映射 jesse腾讯云上有个linux的环境,版本比较老了 简书的地址: https://www.jianshu.com/p/b3bf64 ...
- docker安装mysql挂载宿主本地目录资源后无法启动的问题
可能是权限问题,添加--privileged=true参数: docker run -p : --name zsmysql -v $PWD/data:/var/lib/mysql -v $PWD/lo ...
- Docker学习实践 - Docker安装MySql数据库
Docker安装MySQL数据库 1.Ubuntu安装MySQL安装 (1)安装编译源码需要的包 sudo apt-get install make cmake gcc g++ bison libnc ...
- docker 安装mysql mongo
Docker安装Mysql 1.拉取镜像 docker pull mysql/mysql-server 2.运行mysql docker run -d -p : --name [Name] [Imag ...
- 使用docker安装mysql和redis
本文介绍在linux下使用docker安装mysql和redis. 原文地址:代码汇个人博客 http://www.codehui.net/info/59.html 测试环境:centos7.6,do ...
- CentOS 中利用docker安装MySQL
1.前提条件 centos7 且内核版本高于3.10, 可通过命令: uname -r 查看内核版本 2.利用yum 安装docker 安装一些必要的系统工具: sudo yum install -y ...
随机推荐
- numpy 维度与轴的问题
0. 多维数组的显示问题 >> X = np.reshape(np.arange(24), (2, 3, 4)) # 也即 2 行 3 列的 4 个平面(plane) >> X ...
- 三:Java之Applet
首先我要说的是Applet是一种应用程序,它是一种由JAVA编写的小应用程序,通常这样的应用程序都像他的名字一样,是一个非常小的程序,或许有些朋友就会问了,那么它是用来干什么的呢?JAVA程序就是JA ...
- Linux 获得了其首款基于 RISC-V 的多核开源处理器
去年,硅谷创业公司 SiFive 发布了首款开源 SoC(片上系统 System on a Chip),命名为 Freeform Everywhere 310.现在,该公司从嵌入式系统领先一步,发布了 ...
- python下载图片(3)
# -*- coding: utf-8 -*-"""some function by metaphy,2007-04-03,copyleftversion 0.2&quo ...
- Qt翻译---Thread Support in Qt
Thread Support in Qt QT提供线程支持在平台独立的线程类.一个安全线程的传递事件的方式,一个信号槽的链接在线程之中.这使得开发多线程容易.多线程程序也是一个有用的范例为不冻结用户界 ...
- java线:辛格尔顿隐藏ThreadLocal实现线程数据共享
效果图分享: A和B需要共享同一线程,还有一组的相同A和B共享还有一组线程,两组相互之间不受影响. 代码: package cn.itcast.lesson6; import java.util.Ra ...
- WPF IDataErrorInfo使用-数据对象上验证
<Window x:Class="DataBindingExam.MainWindow" xmlns="http://schemas.microsof ...
- VC++ 使用预编译头
一.使用默认的预编译头 要使用预编译头,我们必须指定一个头文件,这个头文件包含我们不会经常改变的代码和其他的头文件,然后我们用这个头文件来生成一个预编译头文件(.pch文件),想必大家都知 ...
- CentOS搭建python开发环境
装了个CentOS 5.5,想在上面搭个python的开发环境,可是还是遇到了很多问题,记录一下过程: 1.python升级 查看python版本 python -V Python 2.4.3 因为p ...
- Windows 10开发基础——启动默认应用的URI
主要内容:通过指定的URI来启动默认的应用(设置,应用商店,地图,人脉) 方法一:直接在XAML中添加如下代码 <TextBlock x:Name="LocationDisabledM ...