Single Instance
Start: Mysqld_safe--user=mysql &
Stop: mysqladmin-u root-proot shutdown
Development scripts
#!/bin/bash#chkconfig: 2345 30 50#date:2017-6-29#author:xcn ([email protected]) #version ultimatespid= "/var/run/mysqld/mysqld.pid" user= "root" # Define User name password pass= "root" path= "/usr/bin". /etc/init.d/functionsfunction usage () {echo "$0 {start| Stop|restart} "exit 1}[ $# -ne 1 ] && usage #当 $ #号等于1则执行usage函数 #start_mysqlfunction start_mysql ( ) {if [ ! -f $PID ]then$path/mysqld_safe --user=mysql & >/ dev/null 2>&1 #一定要全路径以免出错if [ $? -eq 0 ] thenaction "Start mysql" /bin/trueelseaction "Start mysql erro" /bin/ falsefielseecho "Mysqld is running" fi} #stop_mysqlfunction stop_mysql ( ) {$path/ mysqladmin -u $user -P$PASS SHUTDOWN  >/DEV/NULL 2>&1 IF [ $? -EQ 0 ] thenaction "Stop mysql" /bin/trueelseaction "Stop mysql erro" /bin/ Falsefi} #传参判断执行if [ "$" == "Start" ]thenstart_mysqlelif [ "$" == "Stop" ]thenstop_mysqlelif [ "$" == "restart" ]thenstop_mysqlstart_ mysqlelse #不符合以上则打印usage函数usagefi
This article is from the "Little Rookie" blog, please be sure to keep this source http://baishuchao.blog.51cto.com/12918589/1943008
Developing MySQL single-instance or multi-instance startup scripts