• docker 安装 mysql 并且外挂文件目录


    1. 拉取docker 镜像

    docker  pull mysql

    2. 创建挂载目录

    mkdir /docker/mysql/conf
    mkdir /docker/mysql/data
    mkdir /docker/mysql/log

    3. 创建my.cnf文件

    cd /docker/mysql/conf
    vi my.cnf

    4. 插入以下内容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/

    5. 创建并且启动docker

    docker run 
        -p 3306:3306 
        -e MYSQL_ROOT_PASSWORD=test@123 
        -v /docker/mysql/data:/var/lib/mysql 
        -v /docker/mysql/log:/logs 
        -v /docker/mysql/conf/my.cnf:/etc/mysql/my.cnf 
        --name mysql_1 
        --restart=always 
        -d mysql:latest
  • 相关阅读:
    python笔记005-字符串-列表-元组
    Python笔记2 标准数据类型
    VS2010与VAssistX
    【Windows核心编程】Windows常见数据类型
    网络安全加密
    防御 XSS 的七条原则
    用户权限初略设计
    [Android]Handler的消息机制
    java的线程中的Runnable
    [转]永久告别Android的背景选择器Selector!无需切很多图了!
  • 原文地址:https://www.cnblogs.com/Jesse-Li/p/14466493.html
Copyright © 2020-2023  润新知