自己写的收藏下,免得每次都要重写,mark mark mark !
系统约定,mysql编译在/usr/local/mysql下,数据存放路径是/data/mysql,如果你已经在/etc/init.d/下添加了服务来管理启动停止,最好不要再使用这个脚本,不然会有问题,但是解决这个问题也很简单,把mysql-bin.index这个删除掉就行了,再用/etc/init.d/下的服务来管理
#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 & >/dev/null 2>&1
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内容版权声明:除非注明,否则皆为本站原创文章。
转载注明出处:https://sulao.cn/post/375
评论列表