MySQL服務啟動指令碼

來源:互聯網
上載者:User

標籤:mysql

#!/bin/sh
# chkconfig: 2345 21 60
# description: Start mysql and stop mysql scripts.
#filename:mydb_start.sh
#date:2015-12-13
#linuxzkq
#version:v1.0

pidfile="/application/data/mysql/test-D.pid"
mysql_path="/application/mysql"
datadir="/application/data/mysql"
password="oldboy"

. /etc/init.d/functions
#USAGE
USAGE(){
 echo "USAGE $0 {start|stop|restart}"
 exit 1
}
[ $# -ne 1 ] && USAGE

#start_mydb
function start_mysql(){
  cd $mysql_path
  ./bin/mysqld_safe --user=mysql --pid-file=$pidfile >/dev/null 2>&1 &
  if [ $? -eq 0 ]
   then
    action "start mysqld:" /bin/true
  else
    action "start mysqld:" /bin/false
  fi
}

#stop_mydb
function stop_mysql(){
  cd $mysql_path  
  ./bin/mysqladmin -u root -p$password shutdown >/dev/null 2>&1 &
  if [ $? -eq 0 ]
   then
    action "stop mysqld:" /bin/true
  else
    action "stop mysqld:" /bin/false
  fi
}

case "$1" in
   start) start_mysql
          RETVAL=$?
          ;;
    stop) stop_mysql
          RETVAL=$?
          ;;
 restart) stop_mysql
          sleep 2
          start_mysql
          RETVAL=$?
          ;;
       *) echo "Error,please use an USAGE!"  
          USAGE
esac
exit $RETVAL


此指令碼還不是很完善,歡迎各位拍磚指正!

本文出自 “蘭州linux營運” 部落格,請務必保留此出處http://linuxzkq.blog.51cto.com/9379412/1723352

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.