標籤:
自己寫的MySQL的啟動指令碼
指令碼一:
#!/bin/sh. /etc/init.d/functions[ $# -ne 1 ] && {echo "USAGE:{start|stop|restart}"exit 1}start(){if [ -e /data/3307/mysqld.pid ]then echo "MySQL is running."else /application/mysql/bin/mysqld_safe --defaults-file=/data/3307/my.cnf &>/dev/null & action "MySQL is starting" /bin/true exit 0fi}stop(){if [ -e /data/3307/mysqld.pid ]then /application/mysql/bin/mysqladmin -uroot -p123456 -S /data/3307/mysql.sock shutdown &>/dev/null action "MySQL is stoping" /bin/trueelse action "MySQL is stoping" /bin/false exit 1fi}restart(){ stop sleep 2 start}if [ "$1" == "start" ]then startelif [ "$1" == "stop" ]then stopelif [ "$1" == "restart" ]then restartelse echo "USAGE:{start|stop|restart}" fi
指令碼二:
#!/bin/sh. /etc/init.d/functionsstart(){if [ -e /data/3307/mysqld.pid ]then echo "MySQL is running."else /application/mysql/bin/mysqld_safe --defaults-file=/data/3307/my.cnf &>/dev/null & action "MySQL is starting" /bin/true exit 0fi}stop(){if [ -e /data/3307/mysqld.pid ]then /application/mysql/bin/mysqladmin -uroot -p123456 -S /data/3307/mysql.sock shutdown &>/dev/null action "MySQL is stoping" /bin/trueelse action "MySQL is stoping" /bin/false exit 1fi}restart(){ stop sleep 2 start}case $1 in start) start ;; stop) stop ;; restart) restart ;; *) echo "USAGE:$0 {start|stop|restart}" exit 1esac
MySQL的啟動指令碼