MySQL启动关闭脚本

[root@db01-51 scripts]# 
[root@db01-51 scripts]# cat n_m.sh 
#!/bin/bash
a=`/etc/init.d/mysqld status|grep -o SUCCESS`
#b=`/etc/init.d/mysqld status|grep -o "not running"` 
if [ "$a" = "" ]
  then
    echo "################"
    echo "###MySQl down###"
else
  [ $a = "SUCCESS" ]
    echo "######################"
    echo "###MySQL is running###"
fi
menu(){
cat <<EOF
##############################
 ##you cant do it choose: ###
 ##  1.start mysql        ###
 ##  2.stop mysql         ### 
 ##  3.restart mysql      ### 
 ##  4.exit               ###
##############################
EOF
}
menu
read -p "pls input num: " num 
#
if [ "$num" -eq "1" ]
 then
 /etc/init.d/mysqld start
 exit 1
#
fi
  if [ "$num" -eq "2" ] 
  then
  /etc/init.d/mysqld stop
  exit 1
fi
#
if [ "$num" -eq "3" ]
  then  
  /etc/init.d/mysqld restart
  exit 1
fi
[ "$num" -eq "4" ]&&{
  echo "bye!"
  exit 1
}

  

posted @ 2017-03-09 22:07  reborn枪  阅读(101)  评论(0)    收藏  举报