#!/bin/bashmenu(){echo "---欢迎使用MysqL管理服务程序---"echo "# 1.启动服务"echo "# 2.停止服务"echo "# 3.重启服务"echo "# 4.查看状态"echo "# 5.退出程序"echo "-----------------------------"}choice(){ read -p "Please choice a menu[1‐9]:" select}start(){ pID=`netstat -antp | grep -i "Listen" | grep -i "3306" | awk ‘{print }‘ | awk -F"/" ‘{print }‘` if [ ! -n "$pID" ] then service MysqLd start else echo "MysqL is running" fi}stop(){ pID=`netstat -antp | grep -i "Listen" | grep -i "3306" | awk ‘{print }‘ | awk -F"/" ‘{print }‘` if [ ! -n "$pID" ] then echo "MysqL is stoped" else kill -9 $pID fi}restart(){ stop sleep 1 start}status(){ pID=`netstat -antp | grep -i "Listen" | grep -i "3306" | awk ‘{print }‘ | awk -F"/" ‘{print }‘` if [ ! -n "$pID" ] then echo "MysqL is stoped" else echo "MysqL is running" fi}while :do menu choicecase $select in1) start;;2) stop;;3) restart;;4) status;;5) exit;;*)echo "您输入的数字没有对应的菜单"esacdone@H_502_11@ 总结
以上是内存溢出为你收集整理的Linux记录-mysql服务管理shell实现全部内容,希望文章能够帮你解决Linux记录-mysql服务管理shell实现所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)