Multi-instance MySQL startup script

Source: Internet
Author: User

To develop a MySQL multi-instance startup script:

Known MySQL multi-instance start commands are: Mysqld_safe–defaults-file=/data/3306/my.cnf &

The Stop command is: mysqladmin-u root-p123456-s/data/3306/mysql.sock shutdown

Requirements: Implemented with functions, case statements, if statements, and so on.

1#!/bin/SH2[-f/etc/init.d/functions]&&. /etc/init.d/functions| |Exit3 #Define Variables4port=$15Mysql_user=Root6mysql_sock=/data/${port}/Mysql.sock7path=/application/mysql/bin8Retval=09 #Define Start FunctionTen start () { One   if[!-E"$Mysql _sock"]; Then A/bin/SH$Path/mysqld_safe--defaults-file=/data/${port}/my.cnf2>&1>/dev/NULL& -Retval=$? -     if[$RETVAL-eq0]; Then theAction"starting $Port MySQL ..."/bin/true -       Else -Action"starting $Port MySQL ..."/bin/false -     fi +     Else -       Echo "$Port MySQL is Running ..." +   fi A return $RETVAL at } -  - #Define Stop Function - Stop () { -   if[!-E"$Mysql _sock"]; Then -       Echo "$Port MySQL is Stopped ..." in     Else -Read-p"Please Input $Port MySQL Password:"PWD toMysql_pwd=$PWD +$Path/mysqladmin-u ${mysql_user}-p${mysql_pwd}-s/data/${port}/Mysql.sock shutdown -Retval=$? the       if[$RETVAL-eq0]; Then *Action"stopping $Port MySQL ..."/bin/true $       ElsePanax NotoginsengAction"stopping $Port MySQL ..."/bin/false -       fi the   fi + return $RETVAL A } the  +  Case " $" inch - start) $ Start $Retval=$? -         ;; - stop) the Stop -Retval=$?Wuyi         ;; the restart) - Stop Wu         Sleep 3 - Start AboutRetval=$? $         ;; -*) -         Echo-E"usage:$0 {3306|3307|3308} {Start|stop|restart}" -Retval=2 A         ;; + Esac theExit $RETVAL

Multi-instance MySQL startup script

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.