六、例子:开发
MysqL单实例或者多实例启动脚本 已知
MysqL多实例启动命令为:
MysqLd_safe --deafaults-file=/data/3306/my.cnf & 停止命令
MysqLadmin -u root -p123 -S /data/3306/
MysqL.sock shutdown 请完成
MysqL单实例或者多实例启动脚本编写。 要求:用
函数、case语句等实现。 [root@node01 day10]# vi start_db.sh #!/bin/sh # chkcon
fig: 2345 35 67 # description: start rsync and stop rsync scripts. . /etc/init.d/functions path=/usr/bin/ pass=123 user=root function usage(){ echo "$0 {start|stop|restart}" exit 1 } [ $# -ne 1 ] && usage function start_
MysqL(){ $path/
MysqLd_safe --user=
MysqL >/dev/null 2>&1 & if [ $? -eq 0 ] then action "start
MysqL" /bin/true else action "start
MysqL" /bin/false fi } function stop_
MysqL(){
MysqLadmin -u$user -p$pass shutdown >/dev/null 2>&1 if [ $? -eq 0 ] then action "stop
MysqL" /bin/true else action "stop
MysqL" /bin/false fi } case "$1" in start) start_
MysqL RETVAL=$? ;; stop) stop_
MysqL RETVAL=$? ;; restart) stop_
MysqL sleep 2 start_
MysqL RETVAL=$? ;; *) usage esac [root@node01 day10]# sh start_db01.sh start start
MysqL [ OK ] [root@node01 day10]# sh start_db01.sh stop stop
MysqL [ OK ] [root@node01 day10]# sh start_db01.sh restart stop
MysqL [
Failed] start
MysqL [ OK ] [root@node01 day10]#
MysqL -uroot -p123 Welcome to the
MysqL monitor. Commands end with ; or \g. Your
MysqL connection id is 1 Server version: 5.1.73 Source
distribution
copyright (c) 2000,2013,Oracle and/or its affiliates. All rights reserved. Oracle is a registered
Trademark of Oracle Corporation and/or its affiliates. Other names may be
Trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MysqL>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。