MySQL服务启动脚本

#!/bin/sh
# chkconfig: 2345 21 60
# description: Start mysql and stop mysql scripts.
#filename:mydb_start.sh
#date:2015-12-13
#作者:linuxzkq
#version:v1.0

pidfile="/application/data/mysql/test-D.pid"
mysql_path="/application/mysql"
datadir="/application/data/mysql"
password="oldboy"

. /etc/init.d/functions
#USAGE
USAGE(){
 echo "USAGE $0 {start|stop|restart}"
 exit 1
}
[ $# -ne 1 ] && USAGE

#start_mydb
function start_mysql(){
  cd $mysql_path 
  ./bin/mysqld_safe --user=mysql --pid-file=$pidfile >/dev/null 2>&1 &
  if [ $? -eq 0 ]
   then
    action "start mysqld:" /bin/true
  else
    action "start mysqld:" /bin/false
  fi
}

#stop_mydb
function stop_mysql(){
  cd $mysql_path  
  ./bin/mysqladmin -u root -p$password shutdown >/dev/null 2>&1 &
  if [ $? -eq 0 ]
   then
    action "stop mysqld:" /bin/true
  else
    action "stop mysqld:" /bin/false
  fi
}

case "$1" in
   start) start_mysql
          RETVAL=$?
          ;;
    stop) stop_mysql
          RETVAL=$?
          ;;
 restart) stop_mysql
          sleep 2 
          start_mysql
          RETVAL=$?
          ;;
       *) echo "Error,please use an USAGE!"  
          USAGE
esac
exit $RETVAL


此脚本还不是很完善,欢迎各位拍砖指正!


你可能感兴趣的:(mysql,null,version,start,password)