#!/bin/sh
. /etc/init.d/functions
path=/application/mysql/bin
user=root
pass=123456
function usage(){
echo "$0 {statrt|stop|restart}"
echo 1
}
[ $# -ne 1 ] && usage
function start_mysql(){
$path/mysqld_safe --user=mysql >/dev/null 2>&1 &
if [ $? -eq 0 ]
then
action "start mysql" /bin/true
else
action "start mysql" /bin/false
fi
}
function stop_mysql(){
mysqladmin -u $user -p$pass shutdown >/dev/null 2>&1
if [ $? -eq 0 ]
then
action "stop mysql" /bin/true
else
action "stop mysql" /bin/false
fi
}
if [ "$1" == "start" ]
then
start_mysql
elif [ "$1" == "stop" ]
then
stop_mysql
elif [ "$1" == "restart" ]
then
stop_mysql
start_mysql
else
useage
fi
mysql服务操作shell脚本
最新推荐文章于 2024-03-16 22:30:00 发布