12.4.5.8 SHOW DATABASES Syntax

SHOW DATABASES [LIKE 'pattern']

SHOW DATABASES lists the
databases on the MySQL server host. As of MySQL 4.0.2, you see
only those databases for which you have some kind of privilege,
if you do not have the global SHOW
DATABASES privilege. You can also get this list using
the mysqlshow command.

MySQL implements databases as directories in the data directory,
so this statement simply lists directories in that location.
However, the output may include names of directories that do not
correspond to actual databases.

User Comments

Hopefully useful to have documented here - if you need to dynamically determine the active database, SELECT DATABASE(); will return one row containing the current database name for the active connection.