Centos7安装 mysql5.6.29 shell脚本
本文实例为大家分享了mysql5.6.29的shell脚本,供大家参考,具体内容如下
创建脚本mysql.sh,直接运行shmysql.sh
#!/bin/bash if[-d/software];then cd/software else mkdir/software&&cd/software fi #isexistcommand,ifnot,yuminstall is_exist(){ which$1 if[$?-ne0];then yum-yinstall$1 fi } #dolownadthemysqlinstallpackage,ifexist,checkthemd5sum,ifcorrect,tar;elsermanddownload if[-fmysql-5.6.29.tar.gz];then mysql_md5=`md5summysql-5.6.29.tar.gz|cut-d""-f1` mysql_md5_true="aaa21c6450adee3a1894fd1710f02bf5" if["$mysql_md5"="$mysql_md5_true"];then tar-zxvfmysql-5.6.29.tar.gz else rm-rfmysql-5.6.29.tar.gz rm-rfmysql-5.6.29 fi else is_existwget wgethttp://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.29.tar.gz tar-zxvfmysql-5.6.29.tar.gz fi #seetheyumsourceisuse yumcleanup yummakecache #installthedependpackage yum-yinstallgccmakecmakencurses-devellibxml2-devellibtool-ltdl-develgcc-c++autoconfautomakebisonzlib-devel #addmysqlgroupanduser is_user_mysql=`cat/etc/passwd|awk-F":"'{print$1}'|grepmysql` is_group_mysql=`cat/etc/group|awk-F":"'{print$1}'|grepmysql` if["$is_group_mysql"!="mysql"];then groupaddmysql fi if["$is_user_mysql"!="mysql"];then useradd-r-s/sbin/nologin-gmysqlmysql fi #compileandinstall cdmysql-5.6.29 cmake. make&&makeinstall chown-Rmysql.mysql/usr/local/mysql #initdatabase /usr/local/mysql/scripts/mysql_install_db--user=mysql--basedir=/usr/local/mysql/--datadir=/usr/local/mysql/data #copytheimportantfileto/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 #usedatabase /usr/local/mysql/bin/mysqld_safe--user=mysql& cp/usr/local/mysql/support-files/mysql.server/etc/init.d/mysqld chkconfig--addmysqld chkconfigmysqldon `ln-s/var/lib/mysql/mysql.sock/tmp/mysql.sock` #starttheservice servicemysqldrestart #importenvironment PATH=$PATH:/usr/local/mysql/bin echo"exportPATH=$PATH:/usr/local/mysql/bin>>/etc/profile" source/etc/profile
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持毛票票。