zoukankan      html  css  js  c++  java
  • MySQL的启动脚本

    自己写的MySQL的启动脚本

    脚本一:

    #!/bin/sh
    
    . /etc/init.d/functions
    [ $# -ne 1 ] && {
    echo "USAGE:{start|stop|restart}"
    exit 1
    }
    start(){
    if [ -e /data/3307/mysqld.pid ]
    then
      echo "MySQL is running."
    else
      /application/mysql/bin/mysqld_safe --defaults-file=/data/3307/my.cnf &>/dev/null &
      action  "MySQL is starting" /bin/true
      exit 0
    fi
    }
    
    stop(){
    if [ -e /data/3307/mysqld.pid ]
    then
      /application/mysql/bin/mysqladmin -uroot -p123456 -S /data/3307/mysql.sock shutdown &>/dev/null
      action "MySQL is stoping" /bin/true
    else
      action "MySQL is stoping" /bin/false
      exit 1
    fi
    }
    
    restart(){
      stop
      sleep 2
      start
    }
    
    if [ "$1" == "start" ]
    then
      start
    elif [ "$1" == "stop" ]
    then
      stop
    elif [ "$1" == "restart" ]
    then
      restart
    else
      echo "USAGE:{start|stop|restart}" 
    fi

    脚本二:

    #!/bin/sh
    
    . /etc/init.d/functions
    
    start(){
    if [ -e /data/3307/mysqld.pid ]
    then
      echo "MySQL is running."
    else
      /application/mysql/bin/mysqld_safe --defaults-file=/data/3307/my.cnf &>/dev/null &
      action  "MySQL is starting" /bin/true
      exit 0
    fi
    }
    
    stop(){
    if [ -e /data/3307/mysqld.pid ]
    then
      /application/mysql/bin/mysqladmin -uroot -p123456 -S /data/3307/mysql.sock shutdown &>/dev/null
      action "MySQL is stoping" /bin/true
    else
      action "MySQL is stoping" /bin/false
      exit 1
    fi
    }
    
    restart(){
      stop
      sleep 2
      start
    }
    
    case $1 in 
      start)
            start
            ;;
      stop)
            stop
            ;;
      restart)
            restart
            ;;
      *)
            echo "USAGE:$0 {start|stop|restart}"
            exit 1
    esac
  • 相关阅读:
    cookie和session的区别和用法
    JavaScript深浅拷贝
    前端知识
    typescript -- ts
    vue笔记精华部分
    宜人贷项目里-----正则匹配input输入月份规则
    PHP-Socket-阻塞与非阻塞,同步与异步概念的理解
    PHP socket客户端长连接
    PHP exec/system启动windows应用程序,执行.bat批处理,执行cmd命令
    查看局域网内所有ip
  • 原文地址:https://www.cnblogs.com/along1226/p/4988760.html
Copyright © 2011-2022 走看看