Be careful when checking for existence with a like statement!
If in a series of unfortunate events your variable ends up being empty, and you end up executing this:
SHOW DATABASES like '' -- dangerous!
It will return ALL databases, thus telling the calling script that it exists since some rows were returned.
It's much safer and better practice to use an "=" equal sign to test for existence.
The correct and safe way to test for existence should be:
SHOW DATABASES WHERE `database` = 'xxxxx' -- safe way to test for existence
Note that you have to wrap the column name database with backticks, it can't use relaxed syntax in this case.
This way, if the code creating the variable 'xxxxx' returned blank, then SHOW DATABASES will not return ALL databases, but will return an empty set.