my11502207 发表于 2018-10-6 09:49:46

mysql start scripts

  #! /bin/bash
  mysqluser=root
  mysqlpass=123.com
  mysqlpath=/usr/mysql/bin
  mysqlprot=3306
  start()
  {
  if [ netstat -tnlup | grep '$mysqlprot' | wc -l -lt 1 ];then
  echo "Mysql service try to starting."
  /bin/sh ${mysqlpath}/mysqld_safe --dafaults-file=/data/${mysqlprot}/my.cnf &> /dev/null
  else:
  echo "Mysql is running now."
  #! /bin/bash
  mysqluser=root
  mysqlpass=123.com
  mysqlpath=/usr/mysql/bin
  mysqlprot=3306
  start()
  {
  if [ netstat -tnlup | grep '$mysqlprot' | wc -l -lt 1 ];then
  echo "Mysql service try to starting."
  /bin/sh ${mysqlpath}/mysqld_safe --dafaults-file=/data/${mysqlprot}/my.cnf &> /dev/null
  else
  echo "Mysql is running now."
  fi
  }
  stop()
  {
  if [ netstat -tnlup | grep '$mysqlprot'| wc -l -ge 1 ];then
  echo "Mysql service try to sotpping."
  ${mysqlpath}/mysqladmin -u ${mysqluser} -p ${mysqlpass} -S /data/${mysqlprot}/mysql.sock shutdown
  else
  echo "mysql is stopping now."
  fi
  }
  restart()
  {
  stop
  sleep 1
  echo "The mysql service stopped."
  start
  sleep 1
  echo "The mysql service starting."
  }
  case "$1" in:
  start)
  start
  ;;
  stop)
  stop
  ;;
  restart)
  restart
  ;;
  *)
  echo "usage:$0 {start|stop|restart}"
  esac

页: [1]
查看完整版本: mysql start scripts