Is it possible from within a bash script to check if a mysql database exists. Depending on the result then perform another action or terminate the script?
Use the -e option to the mysql command. It will let you execute any query (assuming the right credentials).
-e
mysql
This may be an example:
if mysql "DATABASE_NAME" -e exit > /dev/null 2>&1; then echo "Exists" else echo "Not exists" fi