#!/bin/bash #by LC TOOLSDIR=/application/tools INSTALLDIR=/application CMAKEFILE=$TOOLSDIR/cmake-3.2.2 CMAKETAR=$TOOLSDIR/cmake-3.2.2.tar.gz MYSQLFILE=$TOOLSDIR/mysql-5.5.32 MYSQLTAR=$TOOLSDIR/mysql-5.5.32.tar.gz INSTALLMYSQL=$INSTALLDIR/mysql-5.5.32 DATADIR=/application/mysql-5.5.32/data SOCKDIR=/application/mysql-5.5.32/tmp/mysql.sock . /etc/init.d/functions panduan (){ if [ $? -eq 0 ] then action " $1 " /bin/true else action " $1 " /bin/false exit 1 fi } function checkMySQLDir(){ [ ! -d $TOOLSDIR ] && mkdir -p $TOOLSDIR } function checkMySQLtar(){ if [ -n $MYSQLTAR ] then echo ‘#########################################################################‘ echo ‘ PLEASE DO THIS "Download MySQL in this directory---/application/tools/"‘ echo ‘#########################################################################‘ exit 1 fi #http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.44.tar.gz #http://mirror.yandex.ru/mirrors/ftp.mysql.com/Downloads/MySQL-5.5/mysql-5.5.44.tar.gz #http://files.directadmin.com/services/all/mysql/mysql-5.5.44.tar.gz #https://downloads.mariadb.com/archives/mysql-5.5/mysql-5.5.44-linux2.6-x86_64.tar.gz #http://ftp.ntu.edu.tw/pub/MySQL/Downloads/MySQL-5.5/mysql-5.5.44.tar.gz if [ -n $CMAKETAR ] then echo ‘#########################################################################‘ echo ‘ PLEASE DO THIS "Download cmake in this directory---/application/tools/"‘ echo ‘#########################################################################‘ exit 1 fi #wget http://www.cmake.org/files/v3.3/cmake-3.3.0.tar.gz } function checkMySQLUser(){ if [ `cat /etc/passwd|grep mysql|wc -l` -eq 0 ] then useradd mysql -s /sbin/nologin -M fi } function InstallMySQL(){ cd $TOOLSDIR && yum install ncurses-devel libaio-devel -y && tar xf $CMAKETAR && cd $CMAKEFILE && ./configure && gmake && gmake install && cd ../ && tar xf $MYSQLTAR && cd $MYSQLFILE && cmake . -DCMAKE_INSTALL_PREFIX=$INSTALLMYSQL -DMYSQL_DATADIR=$DATADIR -DMYSQL_UNIX_ADDR=$SOCKDIR -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii -DENABLED_LOCAL_INFILE=ON -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 -DWITHOUT_PARTITION_STORAGE_ENGINE=1 -DWITH_FAST_MUTEXES=1 -DWITH_ZLIB=bundled -DENABLED_LOCAL_INFILE=1 -DWITH_READLINE=1 -DWITH_EMBEDDED_SERVER=1 -DWITH_DEBUG=0 panduan BIANYI make && make install && #ln -s /application/mysql-5.5.32/ /application/mysql && sed -i ‘40 a pathmunge /application/mysql/bin‘ /etc/profile && source /etc/profile chown -R mysql.mysql $INSTALLMYSQL panduan MAKE } function StartMySQL(){ /bin/cp $INSTALLMYSQL/support-files/my-small.cnf /etc/my.cnf echo ‘PATH=/application/mysql/bin:$PATH‘ >>/etc/profile source /etc/profile chown -R mysql.mysql $DATADIR chmod -R 1777 /tmp cd $INSTALLMYSQL/scripts/ ./mysql_install_db --basedir=$INSTALLMYSQL --datadir=$DATADIR/ --user=mysql panduan CHUSHI cd $MYSQLFILE \cp support-files/mysql.server /etc/init.d/mysqld chmod +x /etc/init.d/mysqld /etc/init.d/mysqld start panduan START } main (){ checkMySQLDir checkMySQLtar checkMySQLUser TarMySQL StartMySQL } main
时间: 2024-08-24 09:03:01