From 2cd07d308c7a218bba0e321fa59f3d54d5c522ef Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Mon, 10 Mar 2014 20:32:10 +0100 Subject: Initial commit --- rebasedb | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 rebasedb (limited to 'rebasedb') diff --git a/rebasedb b/rebasedb new file mode 100755 index 0000000..8d80a8a --- /dev/null +++ b/rebasedb @@ -0,0 +1,40 @@ +#!/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 <