Add missing creds

Added the missing credentials in the mysql call. Also changed the prompt in the drop db confirm to be something people are more used to seeing. Added an else case to handle instances in which the database doesn’t exists.
This commit is contained in:
Ted Stresen-Reuter 2020-01-30 21:50:02 +00:00
parent 9fbaab9c9b
commit 2b4a9bdbea

View file

@ -147,10 +147,10 @@ install_db() {
fi

# create database
if [ $(mysql -e 'show databases;' | grep ^$DB_NAME$) ]
if [ $(mysql -e --user="$DB_USER" --password="$DB_PASS" 'show databases;' | grep ^$DB_NAME$) ]
then
echo "Reinstalling will delete the existing test database ($DB_NAME)"
read -p 'Are you sure you want to proceed? [No/Yes]: ' DELETE_EXISTING_DB
read -p 'Are you sure you want to proceed? [y/N]: ' DELETE_EXISTING_DB
shopt -s nocasematch
if [[ $DELETE_EXISTING_DB =~ ^(y|yes)$ ]]
then
@ -160,6 +160,8 @@ install_db() {
echo "Leaving the existing database ($DB_NAME) in place."
fi
shopt -u nocasematch
else
mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA
fi
}