1. yang xiaoyong
  2. woocode

Source

woocode / sa-auto / sh / mysql5.sh

#!/bin/sh

# 更改人: yxy
# 更改内容: 去掉hard code 用户名和密码
SH_DIR=$(dirname $(which $0))
. $SH_DIR/app_env.sh

#$APP_SVR/mysql5/bin/mysqld_safe --datadir=$APP_DBDAT/mysql5_data --pid-file=$APP_DBDAT/mysql5_data/mysql_3307.pid &

#$APP_SVR/mysql5/bin/mysqld_safe --datadir=$APP_DBDAT/mysql5_data --bind-address=127.0.0.1  &
#$APP_SVR/mysql5/bin/mysqld_safe --datadir=$APP_DBDAT/mysql5_data_abc --bind-address=127.0.0.2  &

PIDFILE=$APP_DBDAT/mysql5_data/mysqld.pid
ERR_LOG_DIR=$APP/logs/mysql5
DELAY=5

start() {
    echo "Starting MySQL ..."
    #$APP_SVR/mysql5/bin/mysqld_safe --datadir=$APP_DBDAT/mysql5_data  --pid-file=$PIDFILE &
    test -d $ERR_LOG_DIR || mkdir -p $ERR_LOG_DIR
    $APP_SVR/mysql5/bin/mysqld_safe --datadir=$APP_DBDAT/mysql5_data --pid-file=$PIDFILE --log-error=$ERR_LOG_DIR/mysql5.err &
}

stop() {
    echo Stopping MySQL ...
    test -f $PIDFILE && PID=`cat $PIDFILE` && echo Got pid number: $PID || echo "Could not found pidfile $PIDFILE"
    # 停止时需要睡眠一段时间
    test -n "$PID" && kill $PID && sleep $DELAY;
}

cd /apps/svr/mysql5
if [ "$1" = "stop" ] ; then
   stop
elif [ "$1" = "restart" ]; then
   stop
   start
elif [ "$1" = "start" ]; then
   start
else
	echo "usage: $0 start|stop|restart"
fi