Mrfei 发表于 2018-10-9 07:58:51

MySQL启动脚本

  #bin/bash
  #author merci
  function mysql_start(){
  id=`ps -ef | grep 'mysql' | grep -v 'grep'`
  if [ ! -n "$id" ]
  then
  /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --user=root &
  exit 0
  else
  echo -e "mysql already running !"
  fi
  }
  function mysql_stop(){
  id=`ps -ef | grep 'mysql' | grep -v 'grep'` | awk '{print $2}'
  if [ ! -n "$id" ]
  then
  echo -e "mysql already stopping !"
  else
  for pid in $id
  do
  kill -9 $pid
  echo -e "close process pid :$pid"
  done
  fi
  }
  echo -e "1. start mysql service"
  echo -e "2. stop mysql service"
  read -p "please choose id:" x
  case $x in
  1)
  mysql_start
  ;;
  2)
  mysql_stop
  ;;
  *)
  echo "please input id !!!"
  ;;
  esac

页: [1]
查看完整版本: MySQL启动脚本