Docker CentOS Installation Mysql5.6

Source: Internet
Author: User

The previous essay, "Docker CentOS installation OpenSSH", writes about how to build an SSH service in a basic CentOS image, and then build other services on that basis. This article continues to introduce the MySQL service based on Centos_ssh.

1. Start Centos_sshd Mirror

# Docker Run--net=host-d registry:/centos-sshd-222: v1. 0 /run. SH

Here is the host Mode connection network, after boot can be logged into the container via SSH, after the installation of MySQL can directly restart the container to verify the success.

2. Install MySQL

Yum Install wget -wget http://dev.mysql.com/get/ mysql-community-release-el7-5.noarch.rpm# RPM-IVH mysql-community-release-el7-5Yum  Install mysql-community-server


3. Configuration

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


4. Turn on MySQL

# Mysqld_safe


5, configure root user password, give root remote connection permission

Open another terminal and go to MySQL and execute the following command:

# mysql-u rootmysql> UPDATE mysql.user SET Password = Password ('123456'  root'; MySQL'root'@'%'  '123456' with GRANT option;mysql> Flush privileges;

6. Change the MySQL configuration so that the service ignores case, UTF8 transmission, etc.

#VI/etc/my.cnf# for advice The 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 forThe most important data# cacheinchMysql. Start at -% of Total RAM forDedicated server,Else Ten%. # 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 forreporting servers.# The server defaults is faster fortransactions and fast selects.# Adjust sizes as needed, experiment toFindThe optimal values.# join_buffer_size=128m# sort_buffer_size=2m# read_rnd_buffer_size=2mlower_case_table_names=1DataDir=/var/lib/Mysqlsocket=/var/lib/mysql/Mysql.sockuser=Mysqlmax_allowed_packet=20m# Disabling Symbolic-links are recommended to prevent assorted security riskssymbolic-links=0character-set-server=Utf8init_connect='SET NAMES UTF8'Sql_mode=No_engine_substitution,strict_trans_tables[mysql]default-character-set=utf8# Disabling Symbolic-links are recommended to prevent assorted security risks#symbolic-links=0# RecommendedinchStandard MySQL Setup#sql_mode=No_engine_substitution,strict_trans_tables[mysqld_safe]log-error=/var/log/Mysqld.logpid-file=/var/run/mysqld/mysqld.pid


7. Change the startup script

VI /run. SH #!/bin/bashmkdir /var/run/mysqldchgrp mysql/var/run/mysqld/  chmod g+w /var/run/mysqld//usr/sbin/sshdmysqld_safe

8. Restart the container

PS -acontainer ID        IMAGE                                COMMAND             CREATED             STATUS              PORTS               names9766bd087945        Registry:/centos-sshd-222: v1. 0   " /run.sh "            minutes ago        seconds                           hopeful_hawking     [[email protected] home]# Docker Restart 9766bd0879459766bd087945


9. Verify MySQL and execute on the remaining MySQL-installed servers:

[Email protected] home]# mysql-u root-p123456-h192.168.31.203Welcome to the MySQL Monitor. Commands End With; or \g.your MySQL connectionIDIs1Server 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 FreeSoftware,and You is welcome to modify and redistribute it under the GPL v2 licensetype'Help ;'Or'\h'  forHelp. Type'\c'ToClearThe current input statement.mysql>exitbye[[email protected] home]# MySQL-U root-p123456-h192.168.31.203Welcome to the MySQL Monitor. Commands End With; or \g.your MySQL connectionIDIs2Server 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 FreeSoftware,and You is welcome to modify and redistribute it under the GPL v2 licensetype'Help ;'Or'\h'  forHelp. Type'\c'ToClearThe current input statement.mysql>show databases;+--------------------+| Database |+--------------------+| Information_schema | | MySQL | | Performance_schema |+--------------------+3RowsinchSet (0.00sec) MySQL>


10. Submit to Docker image, this step is mentioned in "Docker CentOS installation OpenSSH", please move to this article.

Docker CentOS Installation Mysql5.6

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.