zoukankan      html  css  js  c++  java
  • mysql启动脚本-my

    #!/bin/sh
    PREFIX=/opt/mysql
    mysql_username="root"
    mysql_password="123456"
    mysql_port=3308
    function_start_mysql()
    {
        printf "Starting MySQL...
    "
        /bin/sh $PREFIX/bin/mysqld_safe --defaults-file=$PREFIX/conf/my${mysql_port}.cnf 2>&1 > /dev/null &
    }
    
    function_stop_mysql()
    {
        printf "Stoping MySQL...
    "
        $PREFIX/bin/mysqladmin -u ${mysql_username} -p${mysql_password} -S /tmp/my${mysql_port}.sock shutdown
    }
    
    function_restart_mysql()
    {
        printf "Restarting MySQL...
    "
        function_stop_mysql
        sleep 5
        function_start_mysql
    }
    
    function_kill_mysql()
    {
        kill -9 $(ps -ef | grep 'bin/mysqld_safe' | grep ${mysql_port} | awk '{printf $2}')
        kill -9 $(ps -ef | grep 'libexec/mysqld' | grep ${mysql_port} | awk '{printf $2}')
    }
    
    if [ "$1" = "start" ]; then
        function_start_mysql
    elif [ "$1" = "stop" ]; then
        function_stop_mysql
    elif [ "$1" = "restart" ]; then
        function_restart_mysql
    elif [ "$1" = "kill" ]; then
        function_kill_mysql
    else
        printf "Usage: $0 {start|stop|restart|kill}
    "
    fi

    #!/bin/sh
    PREFIX=/opt/mysql
    mysql_username="root"
    mysql_password="123456"
    mysql_port=3308
    function_start_mysql()
    {
    printf "Starting MySQL... "
    /bin/sh $PREFIX/bin/mysqld_safe --defaults-file=$PREFIX/conf/my${mysql_port}.cnf 2>&1 > /dev/null &
    }

    function_stop_mysql()
    {
    printf "Stoping MySQL... "
    $PREFIX/bin/mysqladmin -u ${mysql_username} -p${mysql_password} -S /tmp/my${mysql_port}.sock shutdown
    }

    function_restart_mysql()
    {
    printf "Restarting MySQL... "
    function_stop_mysql
    sleep 5
    function_start_mysql
    }

    function_kill_mysql()
    {
    kill -9 $(ps -ef | grep 'bin/mysqld_safe' | grep ${mysql_port} | awk '{printf $2}')
    kill -9 $(ps -ef | grep 'libexec/mysqld' | grep ${mysql_port} | awk '{printf $2}')
    }

    if [ "$1" = "start" ]; then
    function_start_mysql
    elif [ "$1" = "stop" ]; then
    function_stop_mysql
    elif [ "$1" = "restart" ]; then
    function_restart_mysql
    elif [ "$1" = "kill" ]; then
    function_kill_mysql
    else
    printf "Usage: $0 {start|stop|restart|kill} "
    fi

  • 相关阅读:
    Hacking Tools
    SDN 网络系统之 Mininet 与 API 详解
    Rust安装配置
    研华 FWA-3231 单路E3平台
    Netscaler Configuration Architecture
    TCP拥塞控制算法纵横谈-Illinois和YeAH
    TCP协议疑难杂症全景解析
    Windows WMIC命令使用详解(附实例)
    Windows一个文件夹下面最多可以放多少文件
    喝酒游戏,概率分布和卷积
  • 原文地址:https://www.cnblogs.com/hanxiaohui/p/8399191.html
Copyright © 2011-2022 走看看