#!/bin/zsh ## rebasedb --- Recreate a database based on another database. ## Commentary: # Recreate the database specified as the first parameter based on the # database named by the second parameter. Basically this deletes the # database named by the first argument and then copies the database # named by the second argument into its place. # This command asks for the password of the root user to drop, create # and fill the database. It is assumed that the proper rights have # been specified before and that they will be carried over. # For usage information run the program without any arguments. ## Code: if [ ! ${#@} -eq 2 ]; then echo "Usage: $(basename $0) [todb] [fromdb]" echo echo "Rebases TODB on FROMDB so that TODB holds the same schema and " echo "information as FROMDB" exit 1 fi echo -n 'Database root PW (for DB manipulation): ' read -s ROOTPW echo mysql -u root -p"$ROOTPW" -B <