開發mysql單一實例或多執行個體啟動指令碼

來源:互聯網
上載者:User

標籤:開發mysql單一實例或多執行個體啟動指令碼

單一實例

  1. 啟動:mysqld_safe --user=mysql &

    停止:mysqladmin -u root -proot shutdown

  2. 開發指令碼

#!/bin/bash#chkconfig: 2345 30 50#Date:2017-6-29#Author:xcn([email protected])#version UltimatesPID="/var/run/mysqld/mysqld.pid"user="root"       #定義使用者名稱密碼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 [ "$1" == "start" ]thenstart_mysqlelif [ "$1" == "stop" ]thenstop_mysqlelif [ "$1"  == "restart" ]thenstop_mysqlstart_mysqlelse                       #不符合以上則列印usage函數usagefi


本文出自 “小菜鳥” 部落格,請務必保留此出處http://baishuchao.blog.51cto.com/12918589/1943008

開發mysql單一實例或多執行個體啟動指令碼

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.