#!/bin/sh
# chkconfig:2345 21 60
# Description:start MySQL and stop MySQL scripts.
#filename: mydb_start.sh
#date: 2015-12-13
#linuxzkq
#version: v1.0
Pidfile= "/application/data/mysql/test-d.pid"
Mysql_path= "/application/mysql"
Datadir= "/application/data/mysql"
Password= "Oldboy"
. /etc/init.d/functions
#USAGE
USAGE () {
echo "USAGE $ {Start|stop|restart}"
Exit 1
}
[$#-ne 1] && USAGE
#start_mydb
function Start_mysql () {
CD $mysql _path
./bin/mysqld_safe--user=mysql--pid-file= $pidfile >/dev/null 2>&1 &
If [$?-eq 0]
Then
Action "Start mysqld:"/bin/true
Else
Action "Start mysqld:"/bin/false
Fi
}
#stop_mydb
function Stop_mysql () {
CD $mysql _path
./bin/mysqladmin-u Root-p$password shutdown >/dev/null 2>&1 &
If [$?-eq 0]
Then
Action "Stop mysqld:"/bin/true
Else
Action "Stop mysqld:"/bin/false
Fi
}
Case "$" in
Start) Start_mysql
Retval=$?
;;
Stop) Stop_mysql
Retval=$?
;;
Restart) Stop_mysql
Sleep 2
Start_mysql
Retval=$?
;;
*) echo "error,please use of an usage!"
USAGE
Esac
Exit $RETVAL
This script is not very perfect, welcome you to make bricks!
This article is from the "Love the Ops" blog, please be sure to keep this source http://92yunwei.blog.51cto.com/11037409/1728638
MySQL service startup script