mysql 免编译_Mysql5.7免编译版自动安装脚本

1 #!/bin/sh

2 ##########################################3 # this script is created by xuxuedong. #4 # e_mail:365***746@qq.com #5 # qqinfo:365***746#6 # This is install Mysql5.7#7 # version:1.1#8 ##########################################9 . /etc/init.d/functions10 #set env

11 export PATH=$PATH:/bin:/sbin:/usr/sbin12 export LANG="zh_CN.GB18030"

13 packge=/home/admin/tools14

15

16 # Require root to run this script. 判断是否是root用户执行。17 #if [[ "$(whoami)" != "root" ]]; then

18 # echo "Please run this script as root." >&2

19 # exit 1

20 #fi

21 #Show users how to install.让用户选择如何安装22 menu ( ){23

24 cat<

31 }32 menu33 read num34 echo "you choice $num"

35 #upload the packge by user 用户自己上传安装文件36 functionupload(){37 if [ -e $packge ]38 then

39 cd ${packge}&rz40 else

41 mkdir -p ${packge}&cd ${packge}&rz42 fi

43 if [ $? -eq 0]44 then

45 action "THE sofeware is upload to ${packge}" /bin/true

46 else

47 action "THE sofeware is upload fail" /bin/false

48 fi

49 }50 ###############################51 #donwload the packge from URL 用户自己输入下载路径52 functionWGET(){53 whileTrue54 do

55 if [ -e $packge ]56 then

57 cd ${packge}58 read -p "input donwload URL:"URL59 if [$URL !=z ]60 then

61 wget$URL62 if [ $? -eq 0]63 then

64 action "THE sofeware is download to ${packge}" /bin/true

65 break66 else

67 Continue68 fi

69 else

70 mkdir -p ${packge}&cd ${packge}71 fi

72 fi

73 done

74 if [ $? -eq 0]75 then

76 action "THE sofeware is upload to ${packge}" /bin/true

77 else

78 action "THE sofeware is upload fail" /bin/false

79 fi

80 }81 ########################82 ##installMysql 自动安装 可用while循环实现只有输入目录才能执行83 functionInsTall(){84 read -p "input a installdir for install mysql(example /application/newmysql):"installdir85 if [ -e $installdir ]86 then

87 action "THE dir is exist" /bin/true

88 else

89 mkdir -p $installdir90 fi

91 # Installdir =$installdir92 read -p "input a mysqldata_dir for mysql_data(example /application/newmysql/3306data):"mysqldata_dir93 if [ -e $mysqldata_dir ]94 then

95 action "THE dir is exist" /bin/true

96 else

97 mkdir -p $mysqldata_dir98 fi

99 # Mysqldata_dir =$mysqldata_dir100 cd ${packge}101 echo "`ls -l mysql*`"

102 read -p "please input you want to install version:"ver103 tar -zxf $ver -C $installdir104 cd $installdir105 echo "`ls -l `"

106 read -p "please input you want to install version:"installroot_dir107 rm -rf ${mysqldata_dir}/*

108 ${installroot_dir}/bin/mysqld --initialize --basedir=${installdir} --datadir=${mysqldata_dir}109 if [ $? -eq 0 ]110 then111 action "mysql is install initialize" /bin/true112 else113 action "mysql is install initialize false" /bin/false114 exit115 fi116 ln -s ${installroot_dir}/bin $installdir/bin117 cp ${installroot_dir}/support-files/mysql.server /etc/init.d/mysqld118 cp ${installroot_dir}/support-files/my-default.cnf /etc/my.cnf119 cat >>/etc/my.cnf <

161 [mysql]162 no-auto-rehash163 # Remove the next comment character if you are not familiar with SQL164 #safe-updates165 default-character-set = utf8166

167 [myisamchk]168 key_buffer_size = 512M169 sort_buffer_size = 512M170 read_buffer = 8M171 write_buffer = 8M172 EOF173

174 echo "export PATH=$PATH:${installdir}/bin">>/etc/profile175 source /etc/profile176 echo "mysql login password for root is:`cat ${mysqldata_dir}/mysql-error.log | grep password`"177 }178 function quit(){179 if [ "$num" -eq 3 ]180 then181 echo "logout..."182 exit 0183 fi184 }185

186 case $num in187 1)188 upload189 InsTall190 ;;191 2)192 WGET193 InsTall194 ;;195 3)196 quit197 ;;198

199 *)200 echo "USAG:1|2|3"201 esac

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值