• 双 MySQL 启动、停止脚本


    5.5 启动

    #!/bin/bash
    # author: Wang Xiaoqiang
    # func: Start MySQL 5.5
    
    pid=`netstat -lnpt | awk -F '[ /]+' '/3306/ {print $7}'`
    
    [ ! -z $pid ] && echo -e "e[1;31mMySQL 5.5 Is Running...e[0m" && exit 0
    
    /usr/local/mysql5/bin/mysqld_safe --defaults-file=/etc/my.cnf >/dev/null 2>&1 &
    
    [ $? -eq 0 ] && echo -e "e[1;32mMySQL 5.5 Start Success.e[0m" || echo -e "e[1;31mMySQL 5.5 Start Failed.e[0m"
    
    # End

    5.6 启动

    #!/bin/bash
    # author: Wang Xiaoqiang
    # func: Start MySQL 5.6
    
    pid=`netstat -lnpt | awk -F '[ /]+' '/3307/ {print $7}'`
    
    [ ! -z $pid ] && echo -e "e[1;31mMySQL 5.6 Is Running...e[0m" && exit 0
    
    /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my6.cnf >/dev/null 2>&1 &
    
    [ $? -eq 0 ] && echo -e "e[1;32mMySQL 5.6 Start Success.e[0m" || echo -e "e[1;31mMySQL 5.6 Start Failed.e[0m"
    
    # End

    5.5 停止

    #!/bin/bash
    # author: Wang Xiaoqiang
    # func: Stop MySQL 5.5
    
    pid=`netstat -lnpt | awk -F '[ /]+' '/3306/ {print $7}'`
    
    [ -z $pid ] && echo -e "e[1;31mMySQL 5.5 Is Not Running...e[0m" && exit 0
    
    kill $pid >/dev/null 2>&1
    
    [ ! -z $pid ] && echo -e "e[1;32mMySQL 5.5 Stop Success.e[0m" || echo -e "e[1;31mMySQL 5.5 Stop Failed.e[0m"
    
    # End

    5.6 停止

    #!/bin/bash
    # author: Wang Xiaoqiang
    # func: Stop MySQL 5.6
    
    pid=`netstat -lnpt | awk -F '[ /]+' '/3307/ {print $7}'`
    
    [ -z $pid ] && echo -e "e[1;31mMySQL 5.6 Is Not Running...e[0m" && exit 0
    
    kill $pid >/dev/null 2>&1
    
    [ ! -z $pid ] && echo -e "e[1;32mMySQL 5.6 Stop Success.e[0m" || echo -e "e[1;31mMySQL 5.6 Stop Failed.e[0m"
    
    # End
  • 相关阅读:
    第6章 函数 习题
    2. VS使用---HelloWorld
    [计蒜客]小 B 的题目
    [计蒜客] n 子棋
    [博弈]Euclid's Game
    [博弈]A Funny Game
    [博弈]Being a Good Boy in Spring Festival
    [组合数学]Magic 12 Months(坑)
    [PTA]L2-031 深入虎穴 (25 分)
    [天梯赛]L2-029 特立独行的幸福
  • 原文地址:https://www.cnblogs.com/wangxiaoqiangs/p/5640006.html
Copyright © 2020-2023  润新知