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) , , 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 Community Server configuration file.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html [client]
port =
socket = /var/run/mysqld/mysqld.sock [mysqld_safe]
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
nice = [mysqld]
skip-host-cache
skip-name-resolve
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port =
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= # * 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 : -v /usr/share/zoneinfo/Asia/Shanghai:/etc/localtime -v /data/mysql:/var/lib/mysql -eMYSQL_ROOT_PASSWORD=root-password -d mysql:5.7.

启动完成后进入容器连一下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
Server version: 5.7. MySQL Community Server (GPL) Copyright (c) , , 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() |
+---------------------+
| -- :: |
+---------------------+
row in set (0.01 sec)

安装完成。

mysql的docker化安装的更多相关文章

  1. mongodb副本集的docker化安装

    1. 定义 一般只要生产环境就需要考虑冗余设计,保证在某一台服务器由于某种原因宕机后服务还可以正常运行. mongo副本集是一组服务器,其中有一个主服务器(primary),用于处理客户端请求:还有多 ...

  2. mongodb的docker化安装

    查询mongo镜像 docker search mongo 拉取镜像(拉取STARS最多的那个就可以了) docker pull mongo tips:如果拉取不成功,多pull几次就可以了. 使用自 ...

  3. redis的docker化安装

    只需要关注几点: 端口映射 配置文件映射 持久化映射 要做的就是拉取官方镜像并把关注的几个点处理一下就好了: docker pull redis docker run -d -p : -v /data ...

  4. docker化安装grafana

    继续进行docker改造. 1. 找镜像.拉取镜像 [root@devlop ~]# docker search grafana INDEX NAME DESCRIPTION STARS OFFICI ...

  5. [MySQL] MySQL的自己主动化安装部署

    有过MySQL运维的人应该都清楚,线上的MySQL一般都採用源代码编译,由于这样才干够依据企业的各自须要选择要编译的功能,尽管MySQL的源代码编译挺简单的,可是试想一下,假设你有几百台server同 ...

  6. 在docker中安装mysql

    #!/bin/sh # 安装docker # 在docker中安装mysql # 解决了docker容器中无法输入中文的问题 ##########################安装docker # ...

  7. CentOS双机中Docker下安装Mysql并配置互为主从模式

    CentOS双机中Docker下安装Mysql并配置互为主从模式 目录 1.搜索镜像... 1 2.拉取镜像... 1 3.绑定端口: 1 4.配置文件(修改/etc/mysql/my.cnf文件): ...

  8. docker微服务部署之:四、安装docker、docker中安装mysql和jdk1.8、手动构建镜像、部署项目

    docker微服务部署之:三,搭建Zuul微服务项目 1.Centos7安装Docker 详见:Centos7安装Docker 2.Docker中安装jdk1.8 详见:使用Docker构建jdk1. ...

  9. 【docker】【mysql】docker安装mysql,阿里云docker镜像加速器,docker搜索查看远程仓库上的镜像,docker拉取镜像,查看本地所有镜像,查看容器的运行状况,查看容器的详细信息

    在docker上安装mysql有两种方式 1.通过Dockerfile构建 2.直接在docker hub上拉取镜像安装 =================本篇采用方法2=============== ...

随机推荐

  1. Qt QDialog将窗体变为顶层窗体(activateWindow(); 和 raise() )

    m_pLoginDlg->hide(); m_pLoginDlg->activateWindow(); //m_pLoginDlg->raise(); m_pLoginDlg-> ...

  2. Java常用开发组件介绍

    1.Lombok的使用 http://www.cnblogs.com/ywqbj/p/5711691.html 2.Guava的使用 http://www.yiibai.com/guava/

  3. WebView设置透明和设置背景图片的方法

    http://blog.csdn.net/Vincent20111024/article/details/8478219 1. WebView若要设置背景图,直接设置web .setBackgroun ...

  4. C# 两个结构相同的类进行赋值

    假入两个类A类和B类不有任何继承关系,它们属性名相同,怎么给他们互相赋值呢?下面的方法就可以了. public L SetProperties<T, L>(T t) where L : n ...

  5. 三、安装远程工具xshell,使用SFTP传输文件——Linux学习笔记

    A)远程工具 学Linux没有远程工具怎么行,百度了下,发现了xshell这个东西,重点是可以免费. 链接是多简单啊 输入地址,账号就搞定了. 打命令什么的都搞定了,真的感谢这个时代,求学有路啊! 到 ...

  6. 纯CSS画的基本图形

    图形包括基本的矩形.圆形.椭圆.三角形.多边形,也包括稍微复杂一点的爱心.钻石.阴阳八卦等.当然有一些需要用到CSS3的属性,所以在你打开这篇文章的时候,我希望你用的是firefox或者chrome, ...

  7. June 30th 2017 Week 26th Friday

    Love me little and love me long. 不求情意浓,但愿情意久. Some people say beautiful young people are the creatur ...

  8. C#中internal关键字

    对于一些大型的项目,通常由很多个DLL文件组成,引用了这些DLL,就能访问DLL里面的类和类里面的方法.比如,你写了一个记录日志的DLL,任何项目只要引用此DLL就能实现记录日志的功能,这个DLL文件 ...

  9. easyui学习笔记8—在手风琴中加载其他的页面

    在手风琴中加载其他页面和在表格中加载其他的页面有写类似的,就是请求另外一个页面显示数据. 1.先看看引用的资源文件 <link rel="stylesheet" href=& ...

  10. Debian/Kali 安装原生Firefox

    出于种种原因,有很多人信仰原装纯净:就像debian下的iceweasel,有人总想换成firefox.好吧,正好最近29版发布了,我们无视掉这两者哥两好的关系,尝试在Debian/Kali 下安装F ...