Developing MySQL single-instance or multi-instance startup scripts

Source: Internet
Author: User
Tags erro

Single Instance

    1. Start: Mysqld_safe--user=mysql &

      Stop: mysqladmin-u root-proot shutdown

    2. 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

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.