您好,登錄后才能下訂單哦!
單實例
啟動:mysqld_safe --user=mysql &
停止:mysqladmin -u root -proot shutdown
開發(fā)腳本
#!/bin/bash #chkconfig: 2345 30 50 #Date:2017-6-29 #Author:xcn(baishuchao@yeah.net) #version Ultimates PID="/var/run/mysqld/mysqld.pid" user="root" #定義用戶名密碼 pass="root" path="/usr/bin" . /etc/init.d/functions function usage(){ echo "$0 {start|stop|restart}" exit 1 } [ $# -ne 1 ] && usage #當(dāng)$#號等于1則執(zhí)行usage函數(shù) #start_mysql function start_mysql( ){ if [ ! -f $PID ] then $path/mysqld_safe --user=mysql & >/dev/null 2>&1 #一定要全路徑以免出錯 if [ $? -eq 0 ] then action "start mysql" /bin/true else action "start mysql erro" /bin/false fi else echo "mysqld is running" fi } #stop_mysql function stop_mysql( ){ $path/mysqladmin -u $user -p$pass shutdown >/dev/null 2>&1 if [ $? -eq 0 ] then action "stop mysql" /bin/true else action "stop mysql erro" /bin/false fi } #傳參判斷執(zhí)行 if [ "$1" == "start" ] then start_mysql elif [ "$1" == "stop" ] then stop_mysql elif [ "$1" == "restart" ] then stop_mysql start_mysql else #不符合以上則打印usage函數(shù) usage fi
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。