Dual MySQL Start and Stop scripts, mysql Start and Stop scripts
5.5 start
#!/bin/bash# author: Wang Xiaoqiang# func: Start MySQL 5.5pid=`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 start
#!/bin/bash# author: Wang Xiaoqiang# func: Start MySQL 5.6pid=`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
Stop 5.5
#!/bin/bash# author: Wang Xiaoqiang# func: Stop MySQL 5.5pid=`netstat -lnpt | awk -F '[ /]+' '/3306/ {print $7}'`[ -z $pid ] && echo -e "\e[1;31mMySQL 5.5 Is Not Running...\e[0m" && exit 0kill $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
Stop 5.6
#!/bin/bash# author: Wang Xiaoqiang# func: Stop MySQL 5.6pid=`netstat -lnpt | awk -F '[ /]+' '/3307/ {print $7}'`[ -z $pid ] && echo -e "\e[1;31mMySQL 5.6 Is Not Running...\e[0m" && exit 0kill $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