之前一篇随笔《Docker Centos安装Openssh》 写的是如何在基础的centos镜像中搭建ssh服务,在此基础上再搭建其他服务。本文继续介绍在centos_ssh基础上搭建mysql服务。

1、启动centos_sshd镜像

# docker run --net=host -d registry:/centos-sshd-:v1. /run.sh

这里用的是host模式连接的网络,启动之后即可通过ssh登录到容器内部,装上mysql之后可以直接重启容器来验证是否成功。

2、安装mysql

# yum install wget -y
# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
# rpm -ivh mysql-community-release-el7-.noarch.rpm
# yum install mysql-community-server

3、配置

# mysql_install_db --user=mysql --ldata=/var/lib/mysql

4、开启mysql

# mysqld_safe

5、配置root用户密码、赋予root远程连接权限

再开一个终端,进入mysql,执行如下命令:

# mysql -u root

mysql> UPDATE mysql.user SET Password = PASSWORD('') WHERE User = 'root';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '' WITH GRANT OPTION;
mysql> flush privileges;

6、更改mysql配置,使服务忽略大小写、以utf8传输等

# vi /etc/my.cnf

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
[client]
default-character-set=utf8 [mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at % of total RAM for dedicated server, else %.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
lower_case_table_names=
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
max_allowed_packet=20M
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=
character-set-server=utf8
init_connect='SET NAMES utf8' sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[mysql]
default-character-set=utf8 # Disabling symbolic-links is recommended to prevent assorted security risks
#symbolic-links= # Recommended in standard MySQL setup
#sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES [mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

7、更改启动脚本

[root@localhost /]# vi /run.sh

#!/bin/bash
mkdir /var/run/mysqld
chgrp mysql /var/run/mysqld/
chmod g+w /var/run/mysqld/
/usr/sbin/sshd
mysqld_safe

8、重启容器

[root@localhost home]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9766bd087945 registry:/centos-sshd-:v1. "/run.sh" minutes ago Up seconds hopeful_hawking
[root@localhost home]# docker restart 9766bd087945
9766bd087945

9、验证mysql,在其余安装了mysql的服务器上执行:

[root@localhost home]# mysql -u root -p123456 -h192.168.31.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 5.6. MySQL Community Server (GPL) Copyright (c) , , Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> exit
Bye
[root@localhost home]# mysql -u root -p123456 -h192.168.31.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 5.6. MySQL Community Server (GPL) Copyright (c) , , Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
rows in set (0.00 sec) mysql>

10、提交至docker镜像,该步骤在《Docker Centos安装Openssh》中提到过,敬请移步至该文章。

Docker Centos安装Mysql5.6的更多相关文章

  1. Docker Centos安装Redis以及问题处理

    之前一篇文章 Redis安装及主从配置 介绍了redis的安装配置,另一篇文件介绍了 Docker Centos安装Openssh .今天将两篇文件结合一下——在Docker Centos环境下搭建r ...

  2. CentOS安装MySQL-5.6.10+安全配置

    注:以下所有操作均在CentOS 6.5 x86_64位系统下完成. #准备工作# 在安装MySQL之前,请确保已经使用yum安装了各类基础组件,具体见<CentOS安装LNMP环境的基础组件& ...

  3. Linux学习(一)------CentOs安装mysql5.5 数据库

    具体方法和步骤如下所示: 1.第一步就是看linu是否安装了mysql,经过rpm -qa|grep mysql查看到centos下安装了mysql5.1,那就开始卸载咯 2.接下来就是卸载mysql ...

  4. Docker - CentOS 安装 Docker 和 Docker-Compose

    目录 介绍 Docker Docker-Conpose 安装 Docker CE 系统要求 使用 YUM 安装 配置加速器 安装 Docker-Compose 介绍 Docker Docker 是一个 ...

  5. Centos安装MySQL5.6并重置密码

    数据库配置 如果用的是自带的sqllite那么数据库就可以不动 安装MySQL5.6数据库 这里强烈建议用使用5.6, 5.7版本的数据库遇见了很多BUG 安装MySQL wget http://de ...

  6. centos安装mysql5.6的正确姿态

    1.准备工作 a)卸载centos默认软件 yum remove mariadb-libs-5.5.35-3.el7.x86_64 b)安装依赖包 yum install -y perl-Module ...

  7. Docker Centos安装Openssh

    环境介绍: Docker版本:1.5.0 镜像:docker.io:centos latest 操作步骤: 1.启动镜像 docker run -ti centos /bin/bash 2.安装pas ...

  8. Docker - CentOS安装Docker

    如果要在CentOS下安装Docker容器,必须是CentOS 7 (64-bit).CentOS 6.5 (64-bit) 或更高的版本,并要求 CentOS 系统内核高于 3.10. uname ...

  9. CentOS安装mysql5.6

    1. 去官网https://dev.mysql.com/downloads/mysql/5.6.html下载mysql压缩包,选第一个,最大最全的 2. 通过FTP工具比如FileZila存放到目标地 ...

随机推荐

  1. jquery实现input输入框实时输入触发事件代码

    <input id="productName" name="productName" class="wid10" type=" ...

  2. Sqoop -- 用于Hadoop与关系数据库间数据导入导出工作的工具

    Sqoop是一款开源的工具,主要用于在Hadoop相关存储(HDFS.Hive.HBase)与传统关系数据库(MySql.Oracle等)间进行数据传递工作.Sqoop最早是作为Hadoop的一个第三 ...

  3. Jquery判断离开页面时,通过Ajax更新数据(兼容IE,Chrome,FF浏览器)

    现在很多项目都有客户离开网页时,处理一些业务的需求.所以焦点就聚集在了如何获取页面离开事件. 以下是本人在一个项目中需要记录页面浏览时长的处理办法,测试兼容IE,Chrome,FF浏览器 代码如下: ...

  4. js离开或刷新页面检测(且兼容FF,IE,Chrome)

    <!DOCTYPE html> <html> <head> <script> function closeIt() { return confirm(& ...

  5. java学习材料

    java资料大全 http://zz563143188.iteye.com/ it男视野扩展资料 HTTP://WLSAM168.400GB.COM 最全 spring mvc http://jinn ...

  6. JAVA-面向对象-多态

    多态 1.方法重载 2.方法重写 3.对象转型 4.抽象(可以定义类和方法)    (关键字  abstract)   ( 如: public abstract class robot  )(不能修饰 ...

  7. stucts2 基础程序

    参考<Struts2+Hibernate+Spring> index.jsp

  8. 获取网络IP地址

    IPHostEntry iphost = Dns.GetHostEntry(txtDNS.Text);//解析并返回IPHostEntry对象 foreach (IPAddress ip in iph ...

  9. [原创]Scala学习:for,function,lazy

    1.for循环是一个循环控制结构,可以有效地编写需要执行的特定次数的循环.Scalar的循环说明如下的各种形式: 1)Scala中for循环最简单的语法是: for( var x <- Rang ...

  10. [原创]java WEB学习笔记45:自定义HttpFilter类,理解多个Filter 代码的执行顺序,Filterdemo:禁用浏览器缓存的Filter,字符编码的Filter,检查用户是否登陆过的Filter

    本博客为原创:综合 尚硅谷(http://www.atguigu.com)的系统教程(深表感谢)和 网络上的现有资源(博客,文档,图书等),资源的出处我会标明 本博客的目的:①总结自己的学习过程,相当 ...