shell之安裝MySQL

來源:互聯網
上載者:User

標籤:shell mysql

#!/bin/bash#by LCTOOLSDIR=/application/toolsINSTALLDIR=/applicationCMAKEFILE=$TOOLSDIR/cmake-3.2.2CMAKETAR=$TOOLSDIR/cmake-3.2.2.tar.gzMYSQLFILE=$TOOLSDIR/mysql-5.5.32MYSQLTAR=$TOOLSDIR/mysql-5.5.32.tar.gzINSTALLMYSQL=$INSTALLDIR/mysql-5.5.32DATADIR=/application/mysql-5.5.32/dataSOCKDIR=/application/mysql-5.5.32/tmp/mysql.sock. /etc/init.d/functionspanduan (){  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.gzif [ -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=0panduan 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


本文出自 “10886311” 部落格,請務必保留此出處http://10896311.blog.51cto.com/10886311/1723276

shell之安裝MySQL

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.