pkorsch
3/22/2017 - 8:39 PM

Start & Stop MySQLD

Start & Stop MySQLD

#!/bin/bash

########################################################
#   Author: Peter Korsch                               #
#   Database: MySQL                                    #
#   Last modified: 22-March-2017                       #
#   Script version: 0.9                                #
########################################################

### Change variables ###

BASEDIR=/home/mysql/mysql
CONFIG=/home/mysql/my.cnf
SOCKET=/home/mysql/mysql.sock

#######################
echo "#1 Start MYSQLD process"
echo "#2 Stop MYSQLD process"
echo "#3 Status of MYSQLD process"
echo "#4 Exit"
echo "Enter your choice:"
read INPUT
case ${INPUT} in
 1)
	#start mysqld
	cd $BASEDIR; bin/mysqld_safe --defaults-file=${CONFIG} &;;
 2)
	#stop mysqld
	cd $BASEDIR; bin/mysqladmin -uroot -p --socket ${SOCKET} shutdown;;
 3)
	#status
	cd $BASEDIR; bin/mysqladmin -uroot -p --socket ${SOCKET} status ping;;
 4)
	echo 'EXIT';;
esac