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