shell脚本自动安装mysql-5.5.30.doc_第1页
shell脚本自动安装mysql-5.5.30.doc_第2页
shell脚本自动安装mysql-5.5.30.doc_第3页
shell脚本自动安装mysql-5.5.30.doc_第4页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

shell脚本自动安装mysql-5.5.30cmake 编译#!/bin/bash# automatic configure mysql from source code since mysql 5.5# edit by frank hwang# e-mail MyDBA2006# version 1.0# 2013/03/25# check out lockfile whether or not existlockfile=/tmp/$(basename $0)_lockfileif -f $lockfile ;thenpid=$(cat $lockfile)ps -p $pid | grep $pid & /dev/nullif $? = 0 ; thenecho the script is already running ! & exit 16elseecho $ $lockfilefielseecho $ $lockfilefiechoecho * step 1: check whether mysql is already installed?echofor i in mysql mysql-server mysql-test mysql-bench mysql-connector-java mysql-connector-odbc mysql-develdorpm -q $i & /dev/nullif $? = 0 ; thenrpm -e $i -nodeps & /dev/nullecho $i was uninstalledfidoneechoecho * step 2: install packagesechoyum list | grep mysql-server & /dev/nullif $? = 0 ; thenecho YUM installation sources are ready .else echo YUM installation sources are not FOUND !echo please check it !fiyum -y install gcc gcc-c+ flex bison autoconf automake cmake ncurses-devel curl-devel make lynx & /dev/nullechoecho * step 3: configure installation variables for mysqlechoread -p please input mysql_dir (/usr/local/mysql-VERSION): mysql_dirif -d $mysql_dir ; thenecho $mysql_dir is exist, OK !elseecho $mysql_dir is not existread -p make it? (yes/NO): answer -z $answer & answer=noif $answer = yes -o $answer = y ; thenmkdir $mysql_dir & echo $mysql_dir is OK !elseexit 11;fifiread -p please input mysql_data_dir (/mysql/data): mysql_data_dirif -d $mysql_data_dir ; thenecho $mysql_data_dir is exist, OK !elseecho $mysql_data_dir is not existread -p make it? (yes/NO): answer -z $answer & answer=noif $answer = yes -o $answer = y ; thenmkdir $mysql_data_dir & echo $mysql_data_dir is OK !elseexit 12;fifiread -p please input mysql_conf_dir (/mysql/conf): mysql_conf_dirif -d $mysql_conf_dir ; thenecho $mysql_conf_dir is exist, OK !elseecho $mysql_conf_dir is not existread -p make it? (yes/NO): answer -z $answer & answer=noif $answer = yes -o $answer = y ; thenmkdir $mysql_conf_dir & echo $mysql_conf_dir is OK !elseexit 13;fifiechoecho $mysql_direcho $mysql_data_direcho $mysql_conf_dirread -p please confirm again, these variables are correctly? (yes/NO): answer -z $answer & answer=noif $answer = yes -o $answer = y ; thenecho installation will continue .elseread -p drop these directories which have just maked? (YES/no): answer -z $answer & answer=yesif $answer = yes -o $answer = y ; thenrm -rf $mysql_dirrm -rf $mysql_data_dirrm -rf $mysql_conf_direxit 14elseexit 19fifiechoecho * step 4: create group & user = mysqlechogrep mysql /etc/group & /dev/nullif $? = 0 ; thenecho group: mysql is already existelsegroupadd mysqlfigrep mysql /etc/passwd & /dev/nullif $? = 0 ; then echo user: mysql is already existelse useradd -g mysql mysqlfiechoecho * step 5: cmake & make & make test & make installechosrc_dir=$(pwd)/mysql_version=$mysql_dir#/*/#example: mysql_dir=/usr/local/mysql-5.5.30echo $src_dir$mysql_versionif -d $src_dir$mysql_version ; thencd $src_dir$mysql_versionelseecho installation source is not found !exit 20fiecho execute command = cmake . xxx xxx xxxif -f CMakeCache.txt ; thenread -p CMakeCache.txt is already exist, will you cmake again? (yes/NO): answer -z $answer & answer=noif $answer = yes -o $answer = y ; thenmake cleanrm -rf CMakeCache.txtfifikillall mysqld & /dev/nullrm -rf $mysql_data_dir/*rm -rf $mysql_conf_dir/*rm -rf $mysql_dir/*cmake . -DCMAKE_INSTALL_PREFIX=$mysql_dir -DMYSQL_DATADIR=$mysql_data_dir -DSYSCONFDIR=$mysql_conf_dir -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=complex -DENABLED_LOCAL_INFILE=1 -DMYSQL_TCP_PORT=3306 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DWITH_READLINE=1echoecho execute command = makeechomakeread -p cmake & make are finished, will you confirm make install? (yes/NO): answer -z $answer & answer=noif $answer = no -o $answer = n ; thenexit 15firead -p make test before make install? (YES/no): answer -z $answer & answer=yesif $answer = yes -o $answer = y ; thenecho execute command = make test & make installmake testsleep 5make installelseecho execute command = make insallmake installfiechoecho * step 6: edit privileges & confechoalias cp=cpcp -f $mysql_dir/support-files/f $mysql_conf/fsed -i 37a user=mysql $mysql_conf/fgrep $mysql_dir/bin /.bashrcif $? = 1 ;thenecho export PATH=$PATH:$mysql_dir/bin /.bashrcfi. /.bashrc$mysql_dir/scripts/mysql_install_db -user=mysql -datadir=$mysql_data_dir -basedir=$mysql_dir -builddir=$mysql_dirchown -R mysql:mysql $mysql_data_dircp -f $mysql_dir/support-files/mysql.server /etc/init.d/mysqldchmod 755 /etc/init.d/mysqldechoecho * step 7: mysql server startechorm -rf /etc/f & /dev/null/etc/init.d/mysqld startchkconfig -add mysqldechoecho * step 8: mysql testechomysqladmin -u root password redhatmysqladmin -uroot -hlocalhost -P3306

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论