双 MySQL 启动、停止脚本

2018-06-17 22:47:17来源:未知 阅读 ()

新老客户大回馈,云服务器低至5折

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

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:Mysql Replication 主从同步

下一篇:WITH RECURSIVE and MySQL