zoukankan      html  css  js  c++  java
  • docker创建mysql容器,并挂载数据+配置

    新建:/my/mysql/my.cnf (准备挂载配置文件用)

    将以下内容拷贝进去(或者启动一个docker的mysql,并且把/etc/mysql/my.cnf中的内容拷贝出来)

    # Copyright (c) 2016, 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
    
    !includedir /etc/mysql/conf.d/
    !includedir /etc/mysql/mysql.conf.d/
    
    [mysqld]
    sql_mode='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
    lower_case_table_names=0

    运行如下命令

    docker run --privileged=true --name mysql5.7 -p 3306:3306 
    -v /my/mysql/datadir:/var/lib/mysql 
    -v /my/mysql/conf.d:/etc/mysql/conf.d 
    -v /my/mysql/my.cnf:/etc/mysql/my.cnf -e MYSQL_ROOT_PASSWORD=yourpassword -d mysql:5.7

    下面这两行配置是挂载数据

    -v /my/mysql/datadir:/var/lib/mysql
    -v /my/mysql/conf.d:/etc/mysql/conf.d

    挂载mysql配置文件
    -v /my/mysql/my.cnf:/etc/mysql/my.cnf

    启动后修改/my/mysql/my.cnf并重启docker对应mysql容器即可生效配置

    docker ps #找到对应容器ID
    #重启容器
    docker stop 3
    docker start 3
  • 相关阅读:
    HBase Java API 创建表时一直卡住
    HBase Shell常用的命令
    Three.js中自定义控制几何体的点和面的属性
    Three.js中使用材质覆盖属性
    2021.7.28 发布 gcc-11.2
    解决a 标签在ie8下面不下载问题
    sourceTree拉取代码报错:remote: HTTP Basic: Access denied
    javaScript网页版调用百度地图API (支持HTTPS,兼容IE6+)
    js 时间戳与时间的相互转换
    HTB-Pathfinder
  • 原文地址:https://www.cnblogs.com/zxporz/p/11389942.html
Copyright © 2011-2022 走看看