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存放到目标地 ...
随机推荐
- Spring Boot 2 Swagger2
本文将介绍RESTful API的重磅好伙伴Swagger2,它可以轻松的整合到Spring Boot中,并与Spring MVC程序配合组织出强大RESTful API文档. 它既可以减少我们创建文 ...
- python_字符串
1. 字符串的格式化 格式: 说明: (1)转换说明符 (2)格式化操作符右操作数可以是任何东西,如果是元组的话,每一个元素都会被单独格式化. 2. 字符串常用的方法 (1)find int = fi ...
- OSGMFC
在OSG的Demo中找到MFC_OSG类文件. #pragma once #include <osgViewer/Viewer> #include <osgViewer/Viewer ...
- python get方法
dics.get(k,d)get相当于一条if...else...语句.如果参数k在字典dics中,字典将返回dics[k];返回参数d.例子 >>> l = {:, :} > ...
- 用仿ActionScript的语法来编写html5——第九篇,仿URLLoader读取文件
第九篇,仿URLLoader读取文件 先看看最后的代码 function readFile(){ urlloader = new LURLLoader(); urlloader.addEventLis ...
- javascript实例学习之四——javascript分页
话不多少,直接上代码 html代码: <!DOCTYPE html> <html lang="en"> <head> <meta char ...
- System.Threading.Timer使用心得
System.Threading.Timer 是一个使用回调方法的计时器,而且由线程池线程服务,简单且对资源要求不高. "只要在使用 Timer,就必须保留对它的引用."对于任何托 ...
- java学习材料
java资料大全 http://zz563143188.iteye.com/ it男视野扩展资料 HTTP://WLSAM168.400GB.COM 最全 spring mvc http://jinn ...
- Leetcode: String to Integer
Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. ...
- [原创]Scala学习:for,function,lazy
1.for循环是一个循环控制结构,可以有效地编写需要执行的特定次数的循环.Scalar的循环说明如下的各种形式: 1)Scala中for循环最简单的语法是: for( var x <- Rang ...