有很多可以借鉴的地方,故转载:

创建脚本mysql.sh,直接运行sh mysql.sh

!/bin/bash

if [ -d /software ] ;then
cd /software
else
mkdir /software && cd /software
fi

is exist command ,if not,yum install

is_exist() {
which $1
if [ $? -ne 0 ] ;then
yum -y install $1
fi
}

dolownad the mysql install package,if exist,check the md5sum,if correct,tar;else rm and download

if [ -f mysql-5.6.29.tar.gz ] ;then
mysql_md5=md5sum mysql-5.6.29.tar.gz | cut -d " " -f 1
mysql_md5_true="aaa21c6450adee3a1894fd1710f02bf5"
if [ "$mysql_md5" = "$mysql_md5_true" ] ;then
tar -zxvf mysql-5.6.29.tar.gz
else
rm -rf mysql-5.6.29.tar.gz
    rm -rf mysql-5.6.29
fi
else
is_exist wget
wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.29.tar.gz
tar -zxvf mysql-5.6.29.tar.gz
fi

see the yum source is use

yum cleanup
yum makecache

install the depend package

yum -y install gcc make cmake ncurses-devel libxml2-devel libtool-ltdl-devel gcc-c++ autoconf automake bison zlib-devel

add mysql group and user

is_user_mysql=cat /etc/passwd |awk -F ":" '{print $1}' |grep mysql
is_group_mysql=cat /etc/group |awk -F ":" '{print $1}' |grep mysql

if [ "$is_group_mysql" != "mysql" ] ;then
groupadd mysql
fi
if [ "$is_user_mysql" != "mysql" ] ;then
useradd -r -s /sbin/nologin -g mysql mysql
fi

compile and install

cd mysql-5.6.29
cmake .
make && make install

chown -R mysql.mysql /usr/local/mysql

init database

/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data

copy the important file to /etc

cp /usr/local/mysql/my.cnf /etc/my.cnf

sed -i 's/# basedir = ...../basedir = /usr/local/mysql/g' /usr/local/mysql/my.cnf
sed -i 's/# port = ...../port = 3306/g' /usr/local/mysql/my.cnf
sed -i 's/# datadir = ...../datadir = /usr/local/mysql/data/g' /usr/local/mysql/my.cnf
sed -i '/[mysqld]/a\log-error=/usr/local/mysql/log/error.log' /usr/local/mysql/my.cnf

sed -i '/[mysqld]/a\log=/usr/local/mysql/log/log' /usr/local/mysql/my.cnf

sed -i '/[mysqld]/a\log-slow-queries=/usr/local/mysql/log/slowquery.log' /usr/local/mysql/my.cnf

sed -i '/[mysqld]/a\long_query_time=2' /usr/local/mysql/my.cnf
sed -i '/[mysqld]/a\pid-file=/usr/local/mysql/data/mysql.pid' /usr/local/mysql/my.cnf
sed -i '/[mysqld]/a\character-set-server=utf8' /usr/local/mysql/my.cnf

echo "[client] " >> /usr/local/mysql/my.cnf
echo "socket = /var/lib/mysql/mysql.sock" >>/usr/local/mysql/my.cnf

/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data

use database

/usr/local/mysql/bin/mysqld_safe --user=mysql &

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on

ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock

start the service

service mysqld restart

import environment

PATH=$PATH:/usr/local/mysql/bin
echo "export PATH=$PATH:/usr/local/mysql/bin >> /etc/profile"
source /etc/profile

转载:http://www.jb51.net/article/107611.htm

Centos7安装 mysql5.6.29 shell脚本的更多相关文章

  1. Centos7 安装 MySQL5.7

    Centos7 安装 MySQL5.7 一.环境介绍 1.安装包版本介绍 MySQL 有三种安装方式:RPM安装.二进制包安装.源码包安装.我们这篇文章以二进制方式安装MySQL 软件名称 版本 系统 ...

  2. 全自动安装mongoDB数据库的shell脚本

    最近在研究mongoDB数据库,写了个全自动安装mongoDB数据库的shell脚本,仅供参考,欢迎拍砖,内容如下: #!/bin/bash # shell的执行选项: # -n 只读取shell脚本 ...

  3. centos7安装mysql5.7.19及配置远程连接

    centos7安装mysql5.7.19及配置远程连接------https://blog.csdn.net/Lh19931122/article/details/77996213

  4. CentOS7.5源码编译安装mysql5.7.29

    #查看系统版本 [root@ctos3 ~]# cat /etc/redhat-release CentOS Linux release (Core) #下载源码包,需要注意的是mysql5.7 编译 ...

  5. Centos7安装mysql5.6.29shell脚本

    创建脚本mysql.sh,直接运行sh mysql.sh #!/bin/bash if [ -d /software ] ;then cd /software else mkdir /software ...

  6. Centos7安装Mysql5.7方法总结 - 实操手册

    Centos7.x版本下针对Mysql的安装和使用多少跟之前的Centos6之前版本有所不同的,废话就不多赘述了,下面介绍下在centos7.x环境里安装mysql5.7的几种方法:一.yum方式安装 ...

  7. 一个自动安装LNMP的简洁Shell脚本

    此脚本在生产服务器上使用了一年多,本脚本崇尚简单唯美,只需要一个脚本就可以在任何一台有网络的服务器上自动配置LNMP.本脚本会在脚本执行目录下,建packages目录用于存放LNMP所需要的软件.大家 ...

  8. CentOS7安装MySQL5.7及Tomcat8.5

    在CentOS7服务器上部署FR项目应用 一.安装CentOS-7_x86_64 1.CentOS7:带GUI的服务器(FTP服务器.JAVA平台.兼容性程序库.开发工具.安全性工具.系统管理工具): ...

  9. centos7 安装mysql5.7及配置

    一.Mysql 各个版本区别:1.MySQL Community Server 社区版本,开源免费,但不提供官方技术支持.2.MySQL Enterprise Edition 企业版本,需付费,可以试 ...

随机推荐

  1. vue自动路由-单页面项目(非build时构建)

    博客中自动路由的原理? 答:简单点说,就是在请求页面时,根据url进行动态添加路由. 与其它自动路由博客的区别? 目前网上的博客,一般都是在build的时候进行动态路由添加,而本博客,采用的是在获得u ...

  2. Springboot+Thymeleaf框架的button错误

    ---恢复内容开始--- 在做公司项目时,遇到了一个Springboot+Thymeleaf框架问题: 使用框架写网站时,没有标明type类型的button默认成了‘submit’类型,每次点击按钮都 ...

  3. STL 算法介绍

    STL 算法介绍 算法概述 算法部分主要由头文件<algorithm>,<numeric>和<functional>组成.        <algorithm ...

  4. 【刷题】BZOJ 4998 星球联盟

    Description 在遥远的S星系中一共有N个星球,编号为1-N.其中的一些星球决定组成联盟,以方便相互间的交流.但是,组成联盟的首要条件就是交通条件.初始时,在这N个星球间有M条太空隧道.每条太 ...

  5. 【BZOJ1029】建筑抢修(贪心)

    [BZOJ1029]建筑抢修(贪心) 题面 BZOJ 洛谷 题解 感觉自己已经不会贪心了. 很明显的一个想法是按照终止时间排序,然后能选则选. 但是这样子可能会因为前面选择了一个修理时间很长的,导致现 ...

  6. Shell中[]里面的条件判断

    1.字符串判断 str1 = str2 当两个串有相同内容.长度时为真 str1 != str2 当串str1和str2不等时为真 -n str1 当串的长度大于0时为真(串非空) -z str1 当 ...

  7. BZOJ 4316: 小C的独立集 解题报告

    4316: 小C的独立集 Description 图论小王子小C经常虐菜,特别是在图论方面,经常把小D虐得很惨很惨. 这不,小C让小D去求一个无向图的最大独立集,通俗地讲就是:在无向图中选出若干个点, ...

  8. 【bzoj3527】 Zjoi2014—力

    http://www.lydsy.com/JudgeOnline/problem.php?id=3527 (题目链接) 题意 $${F_i=\sum_{j<i} {\frac{q_iq_j}{( ...

  9. More than one file was found with OS independent path 'META-INF/LICENSE' | Error:Could not read \build\intermediates\typedefs.txt (系统找不到指定的文件。)

    FAQ1: Error:Could not read E:\new\PlatformLibrary\CommonLibrary\build\intermediates\typedefs.txt: E: ...

  10. 【题解】Arpa's letter-marked tree and Mehrdad's Dokhtar-kosh paths Codeforces 741D DSU on Tree

    Prelude 很好的模板题. 传送到Codeforces:(* ̄3 ̄)╭ Solution 首先要会DSU on Tree,不会的看这里:(❤ ω ❤). 众所周知DSU on Tree是可以用来处 ...