Created
April 12, 2018 05:27
-
-
Save ankitraturi/4899056a3a4fc3f089f65eb654da74cc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
declare -a dbs | |
unset opt | |
for each in $(echo "show databases;" | mysql -u root) ;do | |
dbs+=($each) | |
done | |
echo " The system found [ ${#dbs[@]} ] databases." ;sleep 2 | |
echo | |
echo "press 1 to run a check" | |
echo "press 2 to run an optimization" | |
echo "press 3 to run a repair" | |
echo "press 4 to run check,repair, and optimization" | |
echo "press q to quit" | |
read input | |
case $input in | |
1) opt="-c" | |
;; | |
2) opt="-o" | |
;; | |
3) opt="-r" | |
;; | |
4) opt="--auto-repair -c -o" | |
;; | |
*) echo "Quitting Application .."; exit 7 | |
;; | |
esac | |
[[ -z $opt ]] && exit 7; | |
echo " running option: mysqlcheck $opt in 5 seconds on all Dbs... "; sleep 5 | |
for ((i=0; i<${#dbs[@]}; i++)) ;do | |
echo "${dbs[$i]} : " | |
mysqlcheck $opt ${dbs[$i]} -u root | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment