Subversion Repositories DevTools

Rev

Blame | Last modification | View Log | RSS feed

#!/bin/sh
#
#   Script to DROP a database
#   Used when an LXR Release is no longer used
#   Tailored to:
#       1) Take database name as an argument
#       2) Only DROP the database if it exists
#
DBNAME=${1?"First argument MUST be a database name"}
DBEXISTS=$(mysql -u lxr -plxrpw --batch --skip-column-names -e "SHOW DATABASES LIKE '"$DBNAME"';" | grep "$DBNAME" > /dev/null; echo "$?")
if [ $DBEXISTS -eq 0 ];then
    echo "A database with the name $DBNAME exists."
    echo "*** MySQL - DROP tree database $DBNAME"
    mysql -u lxr -plxrpw -e "drop database ${DBNAME};"
else
    echo "A database with the name $DBNAME does not exist."
fi