Docker Centos安装Mysql5.6
之前一篇随笔《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的更多相关文章
- Docker Centos安装Redis以及问题处理
之前一篇文章 Redis安装及主从配置 介绍了redis的安装配置,另一篇文件介绍了 Docker Centos安装Openssh .今天将两篇文件结合一下——在Docker Centos环境下搭建r ...
- CentOS安装MySQL-5.6.10+安全配置
注:以下所有操作均在CentOS 6.5 x86_64位系统下完成. #准备工作# 在安装MySQL之前,请确保已经使用yum安装了各类基础组件,具体见<CentOS安装LNMP环境的基础组件& ...
- Linux学习(一)------CentOs安装mysql5.5 数据库
具体方法和步骤如下所示: 1.第一步就是看linu是否安装了mysql,经过rpm -qa|grep mysql查看到centos下安装了mysql5.1,那就开始卸载咯 2.接下来就是卸载mysql ...
- Docker - CentOS 安装 Docker 和 Docker-Compose
目录 介绍 Docker Docker-Conpose 安装 Docker CE 系统要求 使用 YUM 安装 配置加速器 安装 Docker-Compose 介绍 Docker Docker 是一个 ...
- Centos安装MySQL5.6并重置密码
数据库配置 如果用的是自带的sqllite那么数据库就可以不动 安装MySQL5.6数据库 这里强烈建议用使用5.6, 5.7版本的数据库遇见了很多BUG 安装MySQL wget http://de ...
- centos安装mysql5.6的正确姿态
1.准备工作 a)卸载centos默认软件 yum remove mariadb-libs-5.5.35-3.el7.x86_64 b)安装依赖包 yum install -y perl-Module ...
- Docker Centos安装Openssh
环境介绍: Docker版本:1.5.0 镜像:docker.io:centos latest 操作步骤: 1.启动镜像 docker run -ti centos /bin/bash 2.安装pas ...
- Docker - CentOS安装Docker
如果要在CentOS下安装Docker容器,必须是CentOS 7 (64-bit).CentOS 6.5 (64-bit) 或更高的版本,并要求 CentOS 系统内核高于 3.10. uname ...
- CentOS安装mysql5.6
1. 去官网https://dev.mysql.com/downloads/mysql/5.6.html下载mysql压缩包,选第一个,最大最全的 2. 通过FTP工具比如FileZila存放到目标地 ...
随机推荐
- thinkphp添加后台的构思以及添加数据功能
先写个表单提交,这就是个简单的后台了...其实也可以通过phpadmin...phpadmin也叫后台的吧...一切都是为了更方便快捷... 先弄个模板,简单了点,就是为了了解实现的流程和原理 < ...
- Power-BI绿色开发平台
- 【未解决】CImage::Save / Load 导致“线程 0xc224 已退出,返回值为 1 (0x1)”
不知道这个返回值意味着什么,反正只要用到Save/Load就会出现这个情况. 这个链接:http://forums.codeguru.com/showthread.php?354017-The-thr ...
- freemark 判断是否为空 是否存在
<!--1\---><!--判断aaa是否不为空,eclipse插件老报错.---><#if aaa??> ${aaa}</#if><!--2\ ...
- 内存溢出之Tomcat内存配置
设置Tomcat启动的初始内存其初始空间(即-Xms)是物理内存的1/64,最大空间(-Xmx)是物理内存的1/4. 可以利用JVM提供的-Xmn -Xms -Xmx等选项可进行设置 三.实例,以下给 ...
- (转)flexigrid 参数说明
本文为转载 http://simple1024.iteye.com/blog/1171090 项目用到这玩意,像样的API都是英文的,英文不好,所以经过各种搜集,flexigrid就整理了这么多用得上 ...
- DO.NET操作数据库
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- fences(桌面整理软件)与eDiary3.3.3下载链接
fences: http://www.jb51.net/softs/309746.html http://jingyan.baidu.com/article/e8cdb32b6e958337042b ...
- struts_22_xwork校验器列表使用说明
系统提供的校验器列表如下: required (必填校验器,要求field的值不能为null) requiredstring (必填字符串校验器,要求field的值不能为null,并且长度大于0,默认 ...
- java异常类
package shb.java.exception; /** * 测试异常类 * @Package:shb.java.exception * @Description: * @author shao ...