• MySQL实例部署情况

01:MySQL程序安装目录:/data/apps/mysql

02:MySQL实例3306的配置文件为:/data/mysql/3306/my.cnf

03:MySQL实例3306的PID文件为:/data/mysql/3306/mysql.pid

04:MySQL实例3306的socket文件为:/data/mysql/3306/mysql.sock

  • 脚本内容如下
#!/bin/bash
#
# Load OS variables
source /etc/bashrc
source /etc/prefile

# Define variables
RETVAL=
Port=
User=root
Pass=chenliang
Pid=/data/mysql//mysql.pid
Sock=/data/mysql//mysql.sock
My=/data/mysql//my.cnf
Path=/data/apps/mysql/bin

# Determine the user to execute
if [ $UID -ne $RETVAL ];then
    echo "Must be root to run scripts"
    exit
fi

# Load the local functions
[ -f /etc/init.d/functions ] && source /etc/init.d/functions

# Define functions
start(){
        if [ ! -f "$Pid" ];then
           $Path/mysqld_safe --defaults->& &
           RETVAL=$?
            ];then
              action "Start MySQL [3306]" /bin/true
             else
              action "Start MySQL [3306]" /bin/false
           fi
          else
           echo "MySQL 3306 is running"
           exit
       fi
       return $RETVAL
}

stop(){
        if [ -f "$Pid" ];then
           $Path/mysqladmin -u$User -p$Pass -S $Sock shutdown >/dev/>&
           RETVAL=$?
            ];then
              action "Stop MySQL[3306]" /bin/true
             else
              action "Stop MySQL[3306]" /bin/false
           fi
         else
           echo "MySQL [3306] is not running"
           exit
        fi
        return $RETVAL
}

status(){
        if [ -f "$Pid" ];then
            echo "MySQL [3306] is running"
           else
            echo "MySQL [3306] is not running"
        fi
        return $RETVAL
}

# Case call functions
case "$1" in
  start)
        start
        RETVAL=$?
        ;;
  stop)
        stop
        RETVAL=$?
        ;;
  restart)
        stop

        start
        RETVAL=$?
        ;;
  status)
        status
        RETVAL=$?
        ;;
  *)
        echo "USAGE:$0{start|stop|restart|status}"
        exit
esac

# Scripts return values
exit $RETVAL

最新文章

  1. WebApi防重复提交方案
  2. 为Visual Studio更换皮肤和背景图
  3. BZOJ3823 : 定情信物
  4. shell 循环使用
  5. [msf]那些年儿跑过的字典
  6. AC题目简解-dp
  7. Cocos2d-x 学习资料收集
  8. <php>统计整个文件夹的大小
  9. Yii2.0官方高级模板的目录结构分析
  10. Java探秘之基本数据类型和包装类(int,Integer)(一)
  11. mapreduce新旧api对比
  12. Oracle数据库体系结构之进程结构(4)
  13. mongoDB-Cannot change the size of a document in a capped collection:
  14. AQS解析(未完成)
  15. Spring MVC 使用介绍(一)—— 概述
  16. ubuntu上安装docker
  17. Gym - 101480 CERC 15:部分题目题解(队内第N次训练)
  18. 【JEECG技术文档】表单配置-树形表单
  19. CentOS 设置 oracle 开机自动启动
  20. php连接mysql...mysqli和mysql

热门文章

  1. vscode 如何格式化vue(template)html代码 , 保持标签属性不换行
  2. element-ui 的 日历 datetimerange 日期格适化 , 适合1版本
  3. BCGControlBar介绍
  4. Backbone Collection
  5. 深入了解Java虚拟机
  6. wpf之3d基础
  7. Boltzmann 玻尔兹曼机(BM)
  8. 5亿英镑!Imagination同意出售给私募机构Canyon Bridge
  9. php_Ubuntu Linux下为PHP5安装cURL,mysql
  10. Angular路由守卫 canDeactivate