首页 > 数据库技术 > 详细

MySQL的启动脚本

时间:2015-11-23 18:41:55      阅读:328      评论:0      收藏:0      [点我收藏+]

自己写的MySQL的启动脚本

脚本一:

#!/bin/sh

. /etc/init.d/functions
[ $# -ne 1 ] && {
echo "USAGE:{start|stop|restart}"
exit 1
}
start(){
if [ -e /data/3307/mysqld.pid ]
then
  echo "MySQL is running."
else
  /application/mysql/bin/mysqld_safe --defaults-file=/data/3307/my.cnf &>/dev/null &
  action  "MySQL is starting" /bin/true
  exit 0
fi
}

stop(){
if [ -e /data/3307/mysqld.pid ]
then
  /application/mysql/bin/mysqladmin -uroot -p123456 -S /data/3307/mysql.sock shutdown &>/dev/null
  action "MySQL is stoping" /bin/true
else
  action "MySQL is stoping" /bin/false
  exit 1
fi
}

restart(){
  stop
  sleep 2
  start
}

if [ "$1" == "start" ]
then
  start
elif [ "$1" == "stop" ]
then
  stop
elif [ "$1" == "restart" ]
then
  restart
else
  echo "USAGE:{start|stop|restart}" 
fi

脚本二:

#!/bin/sh

. /etc/init.d/functions

start(){
if [ -e /data/3307/mysqld.pid ]
then
  echo "MySQL is running."
else
  /application/mysql/bin/mysqld_safe --defaults-file=/data/3307/my.cnf &>/dev/null &
  action  "MySQL is starting" /bin/true
  exit 0
fi
}

stop(){
if [ -e /data/3307/mysqld.pid ]
then
  /application/mysql/bin/mysqladmin -uroot -p123456 -S /data/3307/mysql.sock shutdown &>/dev/null
  action "MySQL is stoping" /bin/true
else
  action "MySQL is stoping" /bin/false
  exit 1
fi
}

restart(){
  stop
  sleep 2
  start
}

case $1 in 
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart)
        restart
        ;;
  *)
        echo "USAGE:$0 {start|stop|restart}"
        exit 1
esac

 

MySQL的启动脚本

原文:http://www.cnblogs.com/along1226/p/4988760.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!