码迷,mamicode.com
首页 > 数据库 > 详细

mysql start scripts

时间:2018-03-14 10:44:24      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:linux bash

#! /bin/bash
mysqluser=root
mysqlpass=123.com
mysqlpath=/usr/mysql/bin
mysqlprot=3306

start()
{
if [ netstat -tnlup | grep ‘$mysqlprot‘ | wc -l -lt 1 ];then
echo "Mysql service try to starting."
/bin/sh ${mysqlpath}/mysqld_safe --dafaults-file=/data/${mysqlprot}/my.cnf &> /dev/null
else:
echo "Mysql is running now."

#! /bin/bash
mysqluser=root
mysqlpass=123.com
mysqlpath=/usr/mysql/bin
mysqlprot=3306

start()
{
if [ netstat -tnlup | grep ‘$mysqlprot‘ | wc -l -lt 1 ];then
echo "Mysql service try to starting."
/bin/sh ${mysqlpath}/mysqld_safe --dafaults-file=/data/${mysqlprot}/my.cnf &> /dev/null
else
echo "Mysql is running now."

fi
}

stop()
{
if [ netstat -tnlup | grep ‘$mysqlprot‘| wc -l -ge 1 ];then
echo "Mysql service try to sotpping."
${mysqlpath}/mysqladmin -u ${mysqluser} -p ${mysqlpass} -S /data/${mysqlprot}/mysql.sock shutdown
else
echo "mysql is stopping now."
fi
}

restart()
{
stop
sleep 1
echo "The mysql service stopped."
start
sleep 1
echo "The mysql service starting."
}

case "$1" in:
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
echo "usage:$0 {start|stop|restart}"
esac

mysql start scripts

标签:linux bash

原文地址:http://blog.51cto.com/546136/2086312

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!