MySQL的启动脚本

自己写的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

 

转载于:https://www.cnblogs.com/along1226/p/4988760.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值