CENTOS7 compiling and installing MySQL scripts

Source: Internet
Author: User
Tags bz2

#!/bin/bash# mysqld install scripts# display progressprogress  ()  {     b= '     i=0    while [  $i  -le   100 ]    do        printf  "$*:[  %-50s ]%d%%\r "  $b   $i         sleep 0.001         i= ' expr 2 +  $i '          b=# $b     done    echo}# if Centos  versioncentos_version=$ (cat /etc/redhat-release|awk  ' {print $4} ' |cut -b1) wget -o  /dev/null -o /etc/yum.repos.d/centos-base.repo /http://mirrors.aliyun.com/repo/centos-${ centos_version}.repoyum makecacheprogress centos downloadsed -i  ' s/^SELINUX=.*/ Selinux=disabled/g '  /etc/selinux/coNfig;iptables -fsetenforce 0rpm -e --nodeps mysql*cpu_numbers= ' Cat /proc/cpuinfo |grep processor|wc -l ' computer_mem= ' free -m|grep mem|awk  ' {print $2} ' MYSQL_MEM= ' expr  $COMPUTER _mem -  $COMPUTER _mem / 4 ' color_green= "\033[32m" color_red= "\033[31m" Color_bule= "\033[34m" color_yellow= "\033[33m" color_purple= "\033[35m" color_end= "\033[0m" Sleep 0.05;echo   "==================================================";echo;echosleep 0.05;echo -e  "Mysql  5.7.16 on  $COLOR _green centos7_ ' uname -m '   $COLOR _end "sleep 0.05;echo  -e  "your computer is  $COLOR _green  $CPU _numbers  $COLOR _end processes,mysql  memory is ${color_green}${mysql_mem}m${color_end} "sleep 0.05;echo -e " ${COLOR_ Red}your will input mysql ' S root password and mysql ' s memory${COLOR_ END} "; Echo;echosleep 0.05;echo  "==================================================" # are you sure  installread -n1 -t30 -p  "are you sure setup[y/n]?: "  answercase   $answer  in     "y"  |  "y"  )          echo;echo  "Start setup ...";sleep 2;;      "n"  |  "n"  )         echo;echo  -e  "${color_red}cancel setup......${color_end}"          exit 0 ;;      "")         echo;echo -e  "${color_ PURPLE}OVER&NBSP;TIME!!!!! ${color_end} "        exit 0 ;;     *)         echo;echo -e  "${color_red} Error input parameter......${color_end} "       exit 1 ;; esac# check if user is rootif [ $ (id -u)  !=  "0"  ];then     echo  "$COLOR _red sorry:you must be root to run  this script!${color_end} "    exit 1fi# useradd mysqlgroup_name= mysqluser_name=mysqlif [ -z $ (cat /etc/passwd|awk -f:  "{print $1}" |grep  -w  "$USER _name")  -a -z $ (cat /etc/group|awk -f:  "{print $1}" | grep -w  "$GROUP _name")  ]then    useradd -s /sbin/nologin -m  -U  $USER _name 2> /dev/null    if  ( $? ==  "0"  )     then        echo -e   "$ color_green group  $GROUP _name add sucessfully!${color_end} "    fi    else        echo  -e  "${color_purple}user  $USER _name is exsits! ${color_end}" fifor i in  make gcc gcc-c++ bison-devel ncurses-devel perl perl-devel wgetdo     yum -y -q install  $i  > /dev/null     echo -e  "${color_purple} $i  ${color_green}install ok${color_end}" done# download  cmake >= 2.8cmake_version=cmake-3.4.3rm -rf /tmp/cmake*if [ -z $ (which  cmake)  ]then    wget -c --no-check-certificate -q https:// cmake.org/files/v3.4/${cmake_version}.tar.gz -p /tmp    if [ $? = =  "0"  ]    then        Progress  cmake download        echo -e  "${color_green}cmake download  Sucessfully!${color_end} "    else        echo  -e  "${color_red}cmake download failed!${color_end}"          exit 0    fi    tar -zxf /tmp/${cmake_ Version}.tar.gz -c /tmp/ > /dev/null    cd /tmp/${cmake_ version}    ./bootstrap > /dev/null    make & & make install    echo $?else    echo -e  "${color_purple}cmake is exsits ${color_end}" fi# download boost_1.61boost_version= 1.61.0boost_ver= "Boost_1_61_0" for i in bzip2 gcc bzip2-devel bzip2-libs  Python-devel perl-data-dumperdo    yum install -q -y  $i  > /dev/null    echo  -e  "${color_purple} $i  ${color_green}install ok${color_end}" donewget -c -- No-check-certificate -q https://nchc.dl.sourceforge.net/project/boost/boost/${boost_version}/${boost _ver}.tar.bz2 -p /tmpif [ $? ==  "0"  ]then    progress  Boost Download    echo -e  "${color_green}boost download  Sucessfully!${color_end} "    echo -e " ${color_green}decompression ${boost_ Ver}.tar.bz2${color_end} "    cd /tmp;tar -jxf ${BOOST_VER}.tar.bz2     cd ${BOOST_VER}    echo  ' pwd '     ./ bootstrap.sh 2> /dev/null    ./b2 install   2> / dev/nullelse    echo -e  "${color_red}boost download failed!${color_end}"     exit  0fi# download mysqlrm -rf /tmp/mysql-5.*mysql_version=5.6.35wget -c http:// mirrors.sohu.com/mysql/mysql-5.6/mysql-${mysql_version}.tar.gz -p /tmpif [ $? ==   "0"  ]then    echo -e  "${color_purple}mysql ${mysql_version}${" Color_grenn}download sucessfully!${color_end} "else    echo -e " ${COLOR_ Purple}mysql ${mysql_version}${color_red}download failed!${color_end} "ficd /tmp/tar -zxf  /tmp/mysql-${MYSQL_VERSION}.tar.gzcd mysql-${MYSQL_VERSION}if [ -f /etc/my.cnf  ]then    mv /etc/my.cnf /etc/my.cnf__$ (date +%y%m%d) .bakfiecho  "====== ================================================ "echo -e " please input the root  password of mysql:  " read -p  "(default password:root):"  MYSQL_PASSWDif [  $mysqlrootpw  ==  ""  ];then    mysql_passwd= "root" fiecho  "Mysql root ' S password is &NBSP;${MYSQLROOTPW} "echo -e " ${color_purple}please input mysql basedir: ${color _end} "read -p " (default mysql basedir:/usr/local/mysql/) " mysql_homeif [ -z   $MYSQL _home ];then    mysql_home= "/usr/local/mysql" firead -p  "( Default mysql datadir:/usr/local/mysql/data) " MYSQLDB_HOMEif [ -z  $MYSQLDB _home  ];then    mysqldb_home= "/usr/local/mysql/data" fiecho  "========================= ============================== "Cmake -dcmake_install_prefix=${mysql_home}-${mysql_version} -dmysql_ Datadir=${mysqldb_home} -dsysconfdir=/etc -dwith_boost=/usr/local/include/boost -dwith_myisam_ Storage_engine=1 -dmysql_tcp_port=3306 -ddefault_charset=utf8 -dmysql_user=mysql -dextra_charsets=all  -DENABLED_LOCAL_INFILE=1 -DDEFAULT_COLLATION=utf8_general_cimake -j${CPU_NUMBERS} & & make installln -s ${mysql_home}-${mysql_version} ${mysql_home}cp ${mysql_ home}/support-files/my-default.cnf /etc/my.cnfmkdir -p ${mysqldb_home}/logchown -r  Mysql:mysql ${mysql_home}chown -r mysql:mysql ${mysqldb_home}cd ${mysql_home};chmod  +x ./scripts/mysql_install_db${mysql_home}/scripts/mysql_install_db --user=mysql -- Basedir=${mysql_home} --datadir=${mysqldb_home}cat >> /etc/profile <<eofpath=\ $PATH: ${mysql_home}/binexport patheofsource /etc/profile${mysql_home}/support-files/mysql.server  startif [ $? ==  "0"  ]then    echo  "setup " Successfully!enjoy it .... "    source /etc/profileelse    echo  "Mysql start failed" fi 


This article is from the "Stranded," blog, please be sure to keep this source http://yasar.blog.51cto.com/9120455/1913033

CENTOS7 compiling and installing MySQL scripts

Related Article

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.