MySQL service startup script

Source: Internet
Author: User

#!/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 $ {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 "$" in
Start) Start_mysql
Retval=$?
;;
Stop) Stop_mysql
Retval=$?
;;
Restart) Stop_mysql
Sleep 2
Start_mysql
Retval=$?
;;
*) echo "error,please use of an usage!"
USAGE
Esac
Exit $RETVAL


This script is not very perfect, welcome you to make bricks!


This article is from the "Love the Ops" blog, please be sure to keep this source http://92yunwei.blog.51cto.com/11037409/1728638

MySQL service 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.