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