自动化运维——一键安装MySQL
- #!/bin/bash
- #created by Kevin //, modify //
- # -----------------------------------------------------------------------------
- # Installation Script for the auto-deployment EMM(Linux edition)
- # -----------------------------------------------------------------------------
- # -----------------------------------------------------------------------------
- # shell script to install MySQL (default version mysql-community-5.7.)
- echo "-----------------------start install mysql----------------------"
- # Add to mysql user and mysql group
- if [ `grep "mysql" /etc/passwd | wc -l` -eq ];then
- echo "adding user mysql"
- groupadd mysql
- useradd -r -g mysql mysql
- else
- echo "mysql user is exist"
- fi
- # check installed mysql or not
- for i in `rpm -qa | grep "mysql"`
- do
- rpm -e --allmatches $i --nodeps
- done
- # Remove pre-installed on OS MariaDB if exists
- for i in $(rpm -qa | grep mariadb | grep -v grep)
- do
- echo "Deleting rpm --> "$i
- rpm -e --nodeps $i
- done
- # Install mysqlserver
- rpm -ivh mysql-community-server-5.7.-.el7.x86_64.rpm mysql-community-client-5.7.-.el7.x86_64.rpm mysql-community-common-5.7.-.el7.x86_64.rpm mysql-community-libs-5.7.-.el7.x86_64.rpm
- # check the installtation was successful or not
- rpm -qa |grep "mysql"
- if [ $? != ];then
- echo "mysql install fail"| tee $mysql_instlog
- exit
- else
- echo "mysql isntall success"| tee $mysql_instlog
- fi
- # modify configuration files
- cd /etc/
- echo "character_set_server=utf8" >> my.cnf
- # startup the mysql
- systemctl start mysqld
- systemctl status mysqld
- /etc/init.d/mysqld start
- /etc/init.d/mysqld stop
- echo "MySQL Server install successfully!"
- # configuration
- cat /etc/my.cnf
- sed -i '/mysqld/a\skip-grant-tables' /etc/my.cnf
- systemctl restart mysqld
- # mysql -u root mysql
- mysql -u root mysql -e "use mysql;"
- # use mysql
- # update mysql.user set authentication_string=password('root') where user='root' ;
- mysql -u root mysql -e "update mysql.user set authentication_string=password('root') where user='root' ;"
- mysql -u root mysql -e "flush privileges;"
- cat /etc/my.cnf
- sed -i '/skip-grant-tables/s/^/#/' /etc/my.cnf
- # mysql -u root -p
- # SET PASSWORD = PASSWORD('root');
- mysql -u root -proot --connect-expired-password -e "SET PASSWORD = PASSWORD('root');"
- # mysql -u root mysql
- # use mysql;
- mysql -u root -proot -e "use mysql;"
- # update user set host = '%' where user ='root';
- mysql -u root -proot -e "update user set host = '%' where user ='root';"
- # select host, user from user;
- mysql -u root -proot -e "select host, user from user;"
- # exit
- mysql -u root -proot -e "source /usr/src/tools/user.sql;"
- mysql -u root -proot -e "source /usr/src/tools/emm_saas_base.sql;"
- # create a new database, name as "emm_saas_base"
- # mysql -u root -p
- # create database emm_saas_base;
- # mysql -u root -proot -e "create database emm_saas_base;"
- # show databases;
- # mysql -u root -proot -e "show databases;"
- # initdb
- # for x in find . -name "*.sql"
- # do source emm_saas_base.sql
- # done
- # create user & authentication
- # mysql -u root -p
- # CREATE USER 'emm'@'%' IDENTIFIED BY 'emm';
- # GRANT ALL ON *.* TO 'emm'@'%';
- # show user in the DB
- # select host,user from mysql.user;
- mysql -u root -proot -e "select host,user from mysql.user;"
- echo "The MySQL install and config complete! "
- @echo off
- :: created by Kevin Ji 2016/04/08,modify 2016/05/18
- :: -----------------------------------------------------------------------------
- :: Installation Script for the auto-deployment EMM(Windows edition-copy)
- :: -----------------------------------------------------------------------------
- :: Modify EMM_Install script code for windows edition. Add to automatic configure install directory feature.
- :: creat an source package directory,name as "EMM_SRC" and an destination install directory,name as "EMM_DEST".
- md C:\EMM_SRC
- md C:\EMM_DEST
- :: ------------Install MySQL----------------------------------
- C:
- cd C:\EMM_SRC
- start winrar x -r %cd%\mysql-5.7.11-winx64.zip C:\EMM_DEST
- pause
- :: ------------Config MySQL environment variable---------------
- rem set MYSQL_HOME=C:\mysql-5.7.11-winx64
- rem set PATH=%PATH%;C:\mysql-5.7.11-winx64\bin
- setx /M MYSQL_HOME C:\EMM_DEST\mysql-5.7.11-winx64
- setx /M PATH %PATH%;C:\EMM_DEST\mysql-5.7.11-winx64\bin
- :: ------------MySQL installation and initialization------------
- xcopy %cd%\user.sql C:\EMM_DEST\mysql-5.7.11-winx64\bin\
- xcopy %cd%\emm_saas_base.sql C:\EMM_DEST\mysql-5.7.11-winx64\bin\
- C:
- cd C:\EMM_DEST\mysql-5.7.11-winx64\bin
- mysqld -install
- cd C:\EMM_DEST\mysql-5.7.11-winx64\bin
- mysqld --initialize
- :: ------------modify MySQL configuration file-------------------------
- C:
- cd C:\EMM_DEST\mysql-5.7.11-winx64\
- rename C:\EMM_DEST\mysql-5.7.11-winx64\my-default.ini my.ini
- echo character_set_server=utf8 >> my.ini
- xcopy %cd%\my.ini C:\ /e /i /y
- :: ------------modify MySQL-root password------------------------------
- net stop mysql
- echo skip-grant-tables >> my.ini
- ping -n 2 127.0.0.1 >nul
- taskkill /F /IM mysqld.exe
- net start mysql
- cd C:\EMM_DEST\mysql-5.7.11-winx64\bin
- mysql -e "use mysql"
- mysql -e "update mysql.user set authentication_string=password('root') where user='root' ;"
- mysql -e "flush privileges;"
- cd C:\EMM_DEST\mysql-5.7.11-winx64\
- rename my.ini myold.ini
- cd C:\
- xcopy C:\my.ini C:\EMM_DEST\mysql-5.7.11-winx64\
- :: ------------restart MySQL service-------------------------------
- :: taskkill /F /IM mysqld.exe
- net start mysql
- :: ------------Initialization DB-----------------------------------
- cd C:\EMM_DEST\mysql-5.7.11-winx64\
- echo [client] >> my.ini
- echo user=root >> my.ini
- echo password=root >> my.ini
- cd C:\EMM_DEST\mysql-5.7.11-winx64\bin
- mysql --connect-expired-password -e "SET PASSWORD = PASSWORD('root');"
- mysql --connect-expired-password -uroot -proot < C:\EMM_DEST\mysql-5.7.11-winx64\bin\user.sql
- mysql --connect-expired-password -e "use emm_saas_base;"
- mysql --connect-expired-password -uroot -proot < C:\EMM_DEST\mysql-5.7.11-winx64\bin\emm_saas_base.sql
- pause
- echo MySQL Install and configuration complete
至此完结。
自动化运维——一键安装MySQL的更多相关文章
- 自动化运维Ansible安装篇
Ansible自动化工具之--部署篇 ansible是新出现的自动化运维工具,基于Python开发,集合了众多运维工具(puppet.cfengine.chef.func.fabric)的优点,实现了 ...
- CentOSLinux系统中Ansible自动化运维的安装以及利用Ansible部署JDK和Hadoop
Ansible 安装和配置 Ansible 说明 Ansible 官网:https://www.ansible.com/ Ansible 官网 Github:https://github.com/an ...
- 【linux】【jenkins】自动化运维二 安装插件
gitlab安装教程参考:https://www.cnblogs.com/jxd283465/p/11525629.html 1.Maven Integration Plugins Jenkins安装 ...
- Ansible自动化运维工具安装与使用实例
1.准备两台服务器,要确定网络是通的.服务器当然越多越好啦....Ansible的简介和好处我就不多说了,自己看百科去(*╹▽╹*) IP:192.168.139.100 IP:192.168.139 ...
- python自动化运维篇
1-1 Python运维-课程简介及基础 1-2 Python运维-自动化运维脚本编写 2-1 Python自动化运维-Ansible教程-Ansible介绍 2-2 Python自动化运维-Ansi ...
- Inception介绍(MySQL自动化运维工具)
Inception介绍 GitHub:https://github.com/mysql-inception/inception 文档:https://mysql-inception.github.io ...
- 部署MySQL自动化运维工具inception+archer
***************************************************************************部署MySQL自动化运维工具inception+a ...
- 轻量级自动化运维工具Fabric的安装与实践
一.背景环境 在运维工作中,经常会遇到重复性的劳动,这个时候为了效率就必须要使用自动化运维工具. 这里我给大家介绍轻量级自动化运维工具Fabric,Fabric是基于Python语言开发的,是开发同事 ...
- 自动化运维工具之 Ansible 介绍及安装使用
一.初识Ansible 介绍: Absible 使用 模块(Modules)来定义配置任务.模块可以用标准脚本语言(Python,Bash,Ruby,等等)编写,这是一个很好的做法,使每个模块幂等.A ...
随机推荐
- html/css 两个div在同一行
在界面设计的时候,经常需要将两个div在同一行显示. 但是每次都会忘记怎么做,特此随笔,备忘. 如以下要将“第一个div”和“第二个div”显示在同一行: <div id="id1&q ...
- iOS搜索框
在iOS8以前搜索框是作为一个控件添加到TableViewController中, 有系统自带的搜索变量self.searchDisplayController 遵守一个搜索显示的协议<UISe ...
- SVN更改用户名和密码
关于SVN更换用户名和密码的问题,SVN是一个脚本的扩展软件,但是通过客户端更改用户名和密码的时候比较弱智,必须要经过一些操作之后才能出现更改用户名和密码的对话框. 主要的步骤就是“点击鼠标右键选择T ...
- T-SQL利用Row_Number函数实现分页
SQL: CREATE PROCEDURE PagingViewTest ( @currentPageIndex INT, --页序号 @pageSize INT, --页大小 @pageCount ...
- CSS3—3D翻转
本案例主要是css3和html5,不会js也可以做动画◕.◕ 一.首先看下主要需要的样式: perspective transform transition position classList 就这 ...
- MyBatis(3.2.3) - Passing multiple input parameters
MyBatis's mapped statements have the parameterType attribute to specify the type of input parameter. ...
- 感受函数式编程-scala
/** * Created by jx_luo on 2015/3/18. */object test03 { def main(Args:Array[String]): Unit ={ val st ...
- RDD机制实现模型Spark初识
Spark简介 Spark是基于内存计算的大数据分布式计算框架.Spark基于内存计算,提高了在大数据环境下数据处理的实时性,同时保证了高容错性和高可伸缩性. 在Spark中,通过RDD( ...
- Linux 最常用命令小结
1. 文件共享 1).将windows 系统下的文件夹共享到linux的方法: 安装filezilla,设置连接linux 服务器.将文件上传. 2).mRemote 机器连接管理 2. 文件管理命令 ...
- Unity3D设置字体颜色大小,用于游戏分数显示设置等,
最近在学unity3d,慢慢的学会了许多unity的东西,今天记录下unity3d的Label字体大小及颜色的代码,下面是显示游戏中分数的代码,, public static int Score = ...