Guest User

Untitled

a guest
May 31st, 2018
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. read -p "Enter username: " dbuser
  4. read -p "Enter password: " -s dbpass
  5. echo ""
  6.  
  7. callAction()
  8. {
  9. echo "Optimizing all tables in $db"
  10.  
  11. tables=$( mysql -D $db -e "SHOW TABLES\G;"|grep 'Tables_in_'|sed -n 's/.*Tables_in_.*: \([_0-9A-Za-z]*\).*/\1/p' )
  12.  
  13. for table in $tables; do
  14. mysql -u$dbuser -p$dbpass -D $db -e "OPTIMIZE TABLE $table;"
  15. done
  16. }
  17.  
  18. for db in $(echo "show databases" | mysql -u$dbuser -p$dbpass | grep -v Database); do
  19. if [[ $db != information_schema ]] && [[ $db != adminv2 ]] && [[ $db != proftpd ]] && [[ $db != mysql ]] && [[ $db != nowcom_nl ]] && [[ $db != nucommunity_nu ]] && [[ $db != clubworkx ]] ; then
  20. callAction
  21. fi
  22. done
Add Comment
Please, Sign In to add comment