zoukankan      html  css  js  c++  java
  • mysql的docker化安装

    mysql版本有很多,先看下各类版本号说明:

    3.X至5.1.X:这是早期MySQL的版本。常见早期的版本有:4.1.7、5.0.56等。

    5.4.X到5.7.X:这是为了整合MySQL AB公司社区和第三方公司开发的新存储引擎。吸收新的实现算法,更好的支持SMP架构。为提升性能做了大量代码重构。

    6.0.X到7.1.X:这是为了更好推广MySQL Cluster版本,以及提高MySQL性能和稳定性以及新功能。改动MySQL基础功能,从而对Cluster存储引擎提供更有效支持优化。因为发布时间较晚,发布时已经有其他手段解决MySQL集群技术问题,所以并没有很好的推广使用。

    参考地址:https://www.cnblogs.com/mehome/p/9428175.html

    看了版本说明就很好选择想要使用的版本了,由于笔者常用的是5.7.13版本,此处就以此为例,步骤就是先查寻并获取镜像(此处略)。

    镜像获取完成后启动mysql,到容器里面看下配置文件my.conf:

    [root@devlop ~]# sudo docker exec -it mysql bash
    root@b60ba70e2447:/# cat /etc/mysql/
    conf.d/ my.cnf  
    root@b60ba70e2447:/# cat /etc/mysql/my.cnf 
    # Copyright (c) 2014, 2015, 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 Community Server configuration file.
    #
    # For explanations see
    # http://dev.mysql.com/doc/mysql/en/server-system-variables.html
    
    [client]
    port        = 3306
    socket        = /var/run/mysqld/mysqld.sock
    
    [mysqld_safe]
    pid-file    = /var/run/mysqld/mysqld.pid
    socket        = /var/run/mysqld/mysqld.sock
    nice        = 0
    
    [mysqld]
    skip-host-cache
    skip-name-resolve
    user        = mysql
    pid-file    = /var/run/mysqld/mysqld.pid
    socket        = /var/run/mysqld/mysqld.sock
    port        = 3306
    basedir        = /usr
    datadir        = /var/lib/mysql
    tmpdir        = /tmp
    lc-messages-dir    = /usr/share/mysql
    explicit_defaults_for_timestamp
    
    # Instead of skip-networking the default is now to listen only on
    # localhost which is more compatible and is not less secure.
    #bind-address    = 127.0.0.1
    
    #log-error    = /var/log/mysql/error.log
    
    # Disabling symbolic-links is recommended to prevent assorted security risks
    symbolic-links=0
    
    # * IMPORTANT: Additional settings that can override those from this file!
    #   The files must end with '.cnf', otherwise they'll be ignored.
    #
    !includedir /etc/mysql/conf.d/
    root@b60ba70e2447:/# 

    看到配置后,就可以把自己想要的目录持久化出来了,且注意时区转换:

    docker run --name mysqltest -p 3306:3306 -v /usr/share/zoneinfo/Asia/Shanghai:/etc/localtime -v /data/mysql:/var/lib/mysql -eMYSQL_ROOT_PASSWORD=root-password -d mysql:5.7.13

    启动完成后进入容器连一下mysql,并看看时区:

    [root@devlop ~]# docker exec -it mysqltest bash
    root@5446ce5c7ddf:/# mysql -p
    Enter password: 
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 2
    Server version: 5.7.13 MySQL Community Server (GPL)
    
    Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
    
    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> select now();
    +---------------------+
    | now()               |
    +---------------------+
    | 2019-02-22 15:55:59 |
    +---------------------+
    1 row in set (0.01 sec)

    安装完成。

  • 相关阅读:
    Firemonkey 控件设定字型属性及颜色
    ListView 使用 LiveBindings 显示超过 200 条记录
    Firemonkey ListView 获取项目右方「>」(Accessory) 事件
    XE7 Update 1 选 iOS 8.1 SDK 发布 iPhone 3GS 实机测试
    Firemonkey Bitmap 设定像素颜色 Pixel
    Firemonkey 移动平台 Form 显示使用 ShowModal 范例
    XE7 提交 App(iOS 8)提示「does not contain the correct beta entitlement」问题修复
    XE7 Android 中使用 MessageDlg 范例
    导出 XE6 预设 Android Style (*.style) 档案
    修正 Memo 設定為 ReadOnly 後, 無法有複製的功能
  • 原文地址:https://www.cnblogs.com/zqyx/p/10418901.html
Copyright © 2011-2022 走看看