From 2cd07d308c7a218bba0e321fa59f3d54d5c522ef Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Mon, 10 Mar 2014 20:32:10 +0100 Subject: Initial commit --- copydb | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100755 copydb (limited to 'copydb') diff --git a/copydb b/copydb new file mode 100755 index 0000000..df05f44 --- /dev/null +++ b/copydb @@ -0,0 +1,44 @@ +#!/bin/zsh +## copydb --- Create a copy of a database under a new name + +## Commentary: + +# Create a copy of the database specified as the first argument as a +# new database named by the second argument. Making usage: + +# copydb + +# This doesn't try to check for any existing information, it just +# tries to create and copy. It is up to the user to make sure that +# that can actually be done. + +# During execution it asks for the root password of MySQL so it can +# create a new database. It will also ask for another user and its +# password to load the database with, this may still be the same user, +# but allows one to specify different users if necessary. + +## Code: + +echo -n 'Database root PW (for DB creation): ' +read -s ROOTPW +echo + +echo -n 'Database user for new DB: ' +read DBUSER + +echo -n 'Database user PW for new DB: ' +read -s DBPASSW +echo + +mysql -u root -p"$ROOTPW" -B <