• Mysql多实例之mysql服务脚本


    1.

    #init
    port=3306
    mysql_user="root"
    mysql_pwd="cancer"
    CmdPath="/application/mysql/bin"
    mysql_sock="/data/${port}/mysql.sock"
    
    #startup function
    function_start_mysql()
    {
     if [ ! -e "$mysql_sock" ];then
      printf "Starting MySQL...
    "
      /bin/sh ${CmdPath}/mysqld_safe --defaults-file=/data/${port}/my.cnf 2>&1 > /dev/null &
     else
      printf "MySQL is running...
    "
     exit
     fi
    }
    
    
    #stop function
    function_stop_mysql()
    {
          if [ ! -e "$mysql_sock" ];then
            printf "MySQL is stopped...
    "
            exit
          else
            printf "Stoping MySQL...
    "
            ${CmdPath}/mysqladmin -u ${mysql_user} -p${mysql_pwd} -S /data/${port}/mysql.sock shutdown
          fi
    }
    
    #restart function
    function_restart_mysql()
    {
      printf "Restarting MySQL...
    "
      function_stop_mysql
      sleep 2
      function_start_mysql
    }
    
    
    case $1 in 
    start)
     function_start_mysql
    ;;
    stop)
     function_stop_mysql
    ;;
    restart)
     function_restart_mysql
    ;;
    *)
      printf "Usage: /data/${port}/mysql {start|stop|restart}
    "
    esac
    

    http://blog.csdn.net/u011364306/article/details/47814409

    2.

    #!/bin/bash
    mysql_port=3307
    mysql_username="admin"
    mysql_password="password"
    function_start_mysql()
    {
    printf "Starting MySQL...
    "
    /bin/sh /usr/local/mysql/bin/mysqld_safe --defaults-file=/data/dbdata_${mysql_port}/my.cnf 2>&1 > /dev/null &
    }
    function_stop_mysql()
    {
    printf "Stoping MySQL...
    "
    /usr/local/mysql/bin/mysqladmin -u ${mysql_username} -p${mysql_password} -S /data/dbdata_${mysql_port}/mysql.sock shutdown
    }
    function_restart_mysql()
    {
    printf "Restarting MySQL...
    "
    function_stop_mysql
    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}')
    }
    case $1 in
    start)
    function_start_mysql;;
    stop)
    function_stop_mysql;;
    kill)
    function_kill_mysql;;
    restart)
    function_stop_mysql
    function_start_mysql;;
    *)
    echo "Usage: /data/dbdata_${mysql_port}/mysqld {start|stop|restart|kill}";;
    esac
    

      

    http://blog.csdn.net/zhoufoxcn/article/details/73065655?utm_source=tuicool&utm_medium=referral

  • 相关阅读:
    欧拉函数 || [SDOI2008]仪仗队 || BZOJ 2190 || Luogu P2158
    欧拉函数 || Calculation 2 || HDU 3501
    并查集+时光倒流 || [JSOI2008]星球大战starwar || BZOJ 1015 || Luogu P1197
    并查集+启发式合并+LCA思想 || 冷战 || BZOJ 4668
    并查集+优先队列+启发式合并 || 罗马游戏 || BZOJ 1455 || Luogu p2713
    BZOJ-USACO被虐记
    #1
    BZOJ2441: [中山市选2011]小W的问题
    BZOJ2726: [SDOI2012]任务安排
    BZOJ1492: [NOI2007]货币兑换Cash
  • 原文地址:https://www.cnblogs.com/sdadx/p/7662631.html
Copyright © 2020-2023  润新知