本文共 860 字,大约阅读时间需要 2 分钟。
以下是优化后的文章内容:
#!/bin/bash
. /etc/init.d/functions
user=rootpass=888888path=/application/mysql/bin
function usage(){ echo "Usage:$0 {start|stop|restart|}" exit 1}
function start_db(){ $path/mysqld_safe --user=$user > /dev/null & if [ $? -eq 0 ]; then echo "starting MySQL..." true else echo "starting MySQL..." false fi}function stop_db(){ $path/mysqladmin -u$user -p$pass shutdown > /dev/null if [ $? -eq 0 ]; then echo "stoping MySQL..." true else echo "stop MySQL..." false fi}
if [ "$1" == "start" ]; then start_dbelif [ "$1" == "stop" ]; then stop_dbelif [ "$1" == "restart" ]; then stop_db sleep 3 start_dbelse usagefi
# 启动 MySQL./mysqld01.sh start# 停止 MySQL./mysqld01.sh stop# 重启 MySQL./mysqld01.sh restart
本文内容来源于:51CTO技术博客
转载地址:http://pmbfk.baihongyu.com/