创建脚本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 $
if [ $? -ne ] ;then
yum -y install $
fi
} #dolownad the mysql install package,if exist,check the md5sum,if correct,tar;else rm and download
if [ -f mysql-5.6..tar.gz ] ;then
mysql_md5=`md5sum mysql-5.6..tar.gz | cut -d " " -f `
mysql_md5_true="aaa21c6450adee3a1894fd1710f02bf5"
if [ "$mysql_md5" = "$mysql_md5_true" ] ;then
tar -zxvf mysql-5.6..tar.gz
else
rm -rf mysql-5.6..tar.gz
    rm -rf mysql-5.6.
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..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.
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

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

  1. Centos7 安装 MySQL5.7

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

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

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

  3. centos7 安装docker(手动和脚本安装)换源 卸载

    centos7 安装docker(手动和脚本安装)换源 卸载 Docker 要求 CentOS 系统的内核版本高于 3.10 ,查看本页面的前提条件来验证你的CentOS 版本是否支持 Docker ...

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

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

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

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

  6. Linux学习第三步(Centos7安装mysql5.7数据库)

    版本:mysql-5.7.16-1.el7.x86_64.rpm-bundle.tar 前言:在linux下安装mysql不如windows下面那么简单,但是也不是很难.本文向大家讲解了如何在Cent ...

  7. Centos7安装mysql-5.7.19

    Centos7安装Mysql 一 mysql下载 地址: https://dev.mysql.com/downloads/mysql/#downloads 二 在centos7上创建安装文件存放.解压 ...

  8. centos7安装mysql5.7修改设置密码策略

    centos7操作系统在安装mysql5.7社区版之后会有默认密码,通过grep命令在mysqld.log文件中即可找到,如下所示: 标识位置即在初始化安装时mysql的默认密码,然后通过mysql ...

  9. centos7安装MySQL5.7无法设置密码问题

    前言 在使用centos7系统yum方式安装MySQL5.7后 不知道默认密码是多少  知道后没办法修改? 一.找到MySQL密码 service mysqld start vim /var/log/ ...

随机推荐

  1. Java使用Sockt进行通信(2)

    使用TCP协议编写Sockt TCP(Transmission Control Protocol 传输控制协议)是一种面向连接的.可靠的.基于字节流的传输层通信协议,由IETF的RFC 793定义. ...

  2. MyEclipse运行Java出错:could not find the main class:test.program will exit(导入项目)

    自己新建的项目运行没有任何问题.但是我导入的很早以前别人写的项目,然后run就会弹框could not find the main class:test.program will exit 请确认JA ...

  3. java笔记 -- 类与对象

    封装: 从形式上看, 封装是将数据和行为组合在一个包中, 并对对象的使用者隐藏了数据的实现方式. 对象中的数据称为实例域, 操纵数据的过程称为方法. 对于每个特定的类实例(对象)都有一组特定的实例域值 ...

  4. Android中使用Thread线程与AsyncTask异步任务的区别

    最近和几个朋友交流Android开发中的网络下载问题时,谈到了用Thread开启下载线程时会产生的Bug,其实直接用子线程开启下载任务的确是很Low的做法,那么原因究竟如何,而比较高大上的做法是怎样? ...

  5. 虚拟环境之virtualenvwrapper

    原来的virtualenv工具使用特别麻烦,主要体现在以下几点 1 创建虚拟环境的命令太长,太难记 2 管理特别麻烦 3 进入虚拟环境需要找到这个虚拟环境的存放目录才行,如果没有统一的存放目录,很难找 ...

  6. HTML 点击图片放大

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  7. fiddler修改response header

    if(oSession.host.Contains("baidu.com")){//根据host判断 oSession.RequestHeaders.Remove("Ac ...

  8. 记录一个下最近用tensorflow的几个坑

    1, softmax_cross_entropy_with_logits 的中的logits=x*w+b,其中w应该是[nfeats,nclass],b是[nclass]是对输出的每个类上logits ...

  9. Jquery获取元素方法

    Jquery 获取元素的方法分为两种:jQuery选择器.jQuery遍历函数. 1.获取本身: a.只需要一种jQuery选择器 选择器 实例 说明 #Id $('#myId') ID选择器: 可以 ...

  10. [la P5031&hdu P3726] Graph and Queries

    [la P5031&hdu P3726] Graph and Queries Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: ...