Advertisement
Guest User

Untitled

a guest
May 20th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.54 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. MUSER="$1"
  4. MPASS="$2"
  5. MDB="$3"
  6.  
  7. # Detect paths
  8.  MYSQL=$(which mysql)
  9.  AWK=$(which awk)
  10.  GREP=$(which grep)
  11.  
  12. if [ $# -ne 3 ]
  13. then
  14.   echo "Usage: $0 {MySQL-User-Name} {MySQL-User-Password} {MySQL-Database-Name}"
  15.   echo "Change every tables to InnoDB in MySQL."
  16.   exit 1
  17. fi
  18.  
  19. TABLES=$($MYSQL -u $MUSER -p$MPASS $MDB -e 'show tables' | $AWK '{ print $1}' | $GREP -v '^Tables' )
  20.  
  21. for t in $TABLES
  22. do
  23.   echo "Altering $t table in $MDB database..."
  24.   $MYSQL -u $MUSER -p$MPASS $MDB -e "ALTER TABLE $t ENGINE='innodb'"
  25. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement