Docker Centos安装Mysql5.6
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了Docker Centos安装Mysql5.6,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含4313字,纯文字阅读大概需要7分钟。
内容图文
/centos-sshd-222:v1.0 /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-5.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(‘123456‘) WHERE User = ‘root‘; mysql> GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘123456‘ 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 70% of total RAM for dedicated server, else 10%. # 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=1 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=0 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=0 # 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:5000/centos-sshd-222:v1.0 "/run.sh" 38 minutes ago Up 36 seconds hopeful_hawking [root@localhost home]# docker restart 9766bd087945 9766bd087945
9、验证mysql,在其余安装了mysql的服务器上执行:
[root@localhost home]# mysql -u root -p123456 -h192.168.31.203 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.6.25 MySQL Community Server (GPL) Copyright (c) 2000, 2010, 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.203 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.6.25 MySQL Community Server (GPL) Copyright (c) 2000, 2010, 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 | +--------------------+ 3 rows in set (0.00 sec) mysql>
10、提交至docker镜像,该步骤在《Docker Centos安装Openssh》中提到过,敬请移步至该文章。
Docker Centos安装Mysql5.6
标签:
本文系统来源:http://www.cnblogs.com/zhenyuyaodidiao/p/4595649.html
内容总结
以上是互联网集市为您收集整理的Docker Centos安装Mysql5.6全部内容,希望文章能够帮你解决Docker Centos安装Mysql5.6所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。