標籤:開發mysql單一實例或多執行個體啟動指令碼
單一實例
啟動:mysqld_safe --user=mysql &
停止:mysqladmin -u root -proot shutdown
開發指令碼
#!/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單一實例或多執行個體啟動指令碼