#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
MySQL啓動腳本
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.