#! /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 "$" in:
Start
Start
;;
Stop
Stop
;;
Restart
Restart
;;
*)
echo "usage:$0 {Start|stop|restart}"
Esac
MySQL Start scripts