#!/bin/sh
2 [ -f /etc/init.d/functions ]&&. /etc/init.d/functions||exit3 #Define Variables4 Port=$1
5 Mysql_user=root6 Mysql_sock=/data/${Port}/mysql.sock7 Path=/application/mysql/bin8 RETVAL=0
9 #Define Start Function10 start() {11 if [ ! -e "$Mysql_sock" ];then
12 /bin/sh $Path/mysqld_safe --defaults-file=/data/${Port}/my.cnf 2>&1 >/dev/null &
13 RETVAL=$?
14 if [ $RETVAL -eq 0 ];then
15 action "Starting $Port MySQL..." /bin/true
16 else
17 action "Starting $Port MySQL..." /bin/false
18 fi
19 else
20 echo "$Port MySQL is Running..."
21 fi
22 return $RETVAL23 }24
25 #Define Stop Function26 stop() {27 if [ ! -e "$Mysql_sock" ];then
28 echo "$Port MySQL is Stopped..."
29 else
30 read -p "Please Input $Port MySQL Password:"PWD31 Mysql_pwd=$PWD32 $Path/mysqladmin -u ${Mysql_user} -p${Mysql_pwd} -S /data/${Port}/mysql.sock shutdown33 RETVAL=$?
34 if [ $RETVAL -eq 0 ];then
35 action "Stopping $Port MySQL..." /bin/true
36 else
37 action "Stopping $Port MySQL..." /bin/false
38 fi
39 fi
40 return $RETVAL41 }42
43 case "$2" in
44 start)45 start46 RETVAL=$?
47 ;;48 stop)49 stop50 RETVAL=$?
51 ;;52 restart)53 stop54 sleep 3
55 start56 RETVAL=$?
57 ;;58 *)59 echo -e "USAGE:$0 {3306|3307|3308} {start|stop|restart}"
60 RETVAL=2
61 ;;62 esac
63 exit $RETVAL
多实例MySQL启动脚本
标签:ret lease default ini rest code sleep p12 mysql
本条技术文章来源于互联网,如果无意侵犯您的权益请点击此处反馈版权投诉
本文系统来源:http://www.cnblogs.com/bidongweb/p/6961847.html