MySQL startup script

Source: Internet
Author: User

Today in the company, the morning was engaged for one hours, MySQL Single instance startup script is done.

[[email protected] scripts]# cat test3.sh #!/bin/bashretval=0. /etc/init.d/ Functionsbasedir=/application/mysql-5.5.32/bindatadir=/application/mysql-5.5.32/datapsd=123.com hostname= ' Hostname ' menu () {cat <<end======================    1.start     2.stop    3.restart    4.exit======================end}start () {      if [ -f ${datadir}/${hostname}.pid ]         then           action  " Mysql running ... " /bin/false        else            ${basedir}/mysqld_safe --defaults-file=/etc/my.cnf - -user=root >/dev/null 2>&1 &            sleep 2           action  "stutting start  MySQL " /bin/true      fi}stop () {     if [  -f ${datadir}/${hostname}.pid ]        then  &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;${BASEDIR}/MYSQLADMIN&NBSP;-UROOT&NBSP;-P${PSD}  shutdown           sleep 2            action  "Mysql stoping ..."  /bin/true          else            action  "Mysql stoping ..."  /bin/false     fi}restart () {      if [ -f ${datadir}/${hostname}.pid ]          then            ${basedir}/mysqladmin -uroot -p${ psd} shutdown            action  "MySQL  stop ... " /bin/true            sleep  2            ${basedir}/mysqld_safe -- defaults-file=/etc/my.cnf --user=root >/dev/null 2>&1 &             sleep 2             action  "Mysql start ..."  /bin/true          else            action   "Mysql stop ..."  /bin/false             ${basedir}/mysqld_safe --defaults-file=/etc/my.cnf --user=root >/dev/null 2>&1 &             sleep 2             action  "Mysql start ..."  /bin/true      fireturn  $RETVAL}exit () {     exit 1}main () {while truedo      menu     read -p  " mysql masterserver  : " men     case " $men " in         start)            start            RETVAL=$?            ;;         stop)             stop           retval=$?            ;;         restart)             restart           RETVAL=$?            ;;         exit)             exit           ;;         *)             printf  "Choice menus error {start|stop|restart}"             exit 1     esacdoneexit  $RETVAL}main

[Email protected] scripts]# sh test3.sh
======================
1.start
2.stop
3.restart
4.exit
======================
MySQL Masterserver:start
MySQL running ... [FAILED]
======================
1.start
2.stop
3.restart
4.exit
======================
MySQL Masterserver:stop
MySQL stoping ... [OK]
======================
1.start
2.stop
3.restart
4.exit
======================
MySQL Masterserver:start
stutting start MySQL [OK]
======================
1.start
2.stop
3.restart
4.exit
======================
MySQL Masterserver:restart
MySQL stop ... [OK]
MySQL start ... [OK]
======================
1.start
2.stop
3.restart
4.exit
======================
MySQL Masterserver:exit

[Email protected] scripts]#

I believe, I can. Ability and age not related--New Waldray-operation and maintenance of the elder side of the teachings-although only a few days, but you are very humorous, from the graduation, from a lot of people learned many things. Compare let oneself grow is in Lian long Bo Pass of day, although every month buckle pay buckle's still heart uncomfortable

This article from the "Clear Sky" blog, declined reprint!

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