之前一篇随笔《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. jboss\server\default\.\tmp 拒绝访问 axis2

    下载axis2.war包. 下载jboss-4.2.3.GA.zip和jboss-5.0.1.GA.zip两个包并解压. 配置JDK后要配置JBOSS_HOME的环境变量,在Path中配置%JBOSS ...

  2. Java Synchronized的用法

    synchronized是Java中的关键字,是一种同步锁.它修饰的对象有以下几种: 1. 修饰一个代码块,被修饰的代码块称为同步语句块,其作用的范围是大括号{}括起来的代码,作用的对象是调用这个代码 ...

  3. DG - dataguard trouble shooting的相关视图

    •V$DATAGUARD_STATS:显示dataguard统计信息 备库 SQL> select * from v$dataguard_stats; NAME VALUE UNIT TIME_ ...

  4. ViewController 的代码规范

    1.#pragma mark - life cycle viewDidLoad viewWillAppear 2.#pragma mark - delegate #pragma mark collec ...

  5. Aspectj是什么

    转载自:http://www.cnblogs.com/sunwke/articles/2568875.html 网上出现了很多讲解 AspectJ 的资料,但大多是从讲解 AspectJ 语法开始,然 ...

  6. php CI框架目录结构及运行机制

    CI目录结构   CI主要组成部分为,application(应用文件夹).system(系统文件夹)和index.php入口文件.     应用文件夹中主要是存放控制器.模型和视图等,系统文件夹中主 ...

  7. yii框架中保存第三方登录信息

    (第三方登录) 创建应用,域名,详情请看:http://www.cnblogs.com/xujn/p/5287157.html 效果图:

  8. CCF真题之出现次数最多的数

    201312-1 问题描述 给定n个正整数,找出它们中出现次数最多的数.如果这样的数有多个,请输出其中最小的一个. 输入格式 输入的第一行只有一个正整数n(1 ≤ n ≤ 1000),表示数字的个数. ...

  9. JSon_零基础_001_将布尔类型数组转换为JSon格式字符串,返回给界面

    将布尔类型数组转换为JSon格式字符串,返回给界面 需要导入包: 编写bean: package com.west.webcourse.po; /** * 第01步:编写bean类, * 下一步com ...

  10. java 如何接收数据集参数

    @RequestBody String requestBody  可以接收 josn  字符串 ,list 等等 public int updateLoaneePriorityNew(HttpServ ...