#!/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 0 {start|stop|restart}" exit 1 } [0 {start|stop|restart}" exit 1 } [# -ne 1 ] && USAGE
#start_mydb
function start_mysql(){
cd mysqlpath./bin/mysqldsafe−−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 "1" in
start) start_mysql
RETVAL=?;;stop)stopmysqlRETVAL=?
;;
restart) stop_mysql
sleep 2
start_mysql
RETVAL=?;;∗)echo"Error,pleaseuseanUSAGE!"USAGEesacexitRETVAL
此脚本还不是很完善,欢迎各位拍砖指正!
本文转自 linuxzkq 51CTO博客,原文链接:http://blog.51cto.com/linuxzkq/1723352