I give +1 to answer by @chown, but here’s another alternative: If the bash script is running locally with the MySQL instance, and you know the path to the datadir, you can test:
if [ -d /var/lib/mysql/databasename ] ; then
# Do Stuff ...
This also assumes your shell user running the script has filesystem-level privileges to read the contents of the MySQL datadir. This is often the case, but it is not certain.