SHOW DATABASES returns all databases the MySQL server knows about, optionally filtered with LIKE or WHERE.
SHOW DATABASES queries the information_schema and displays every database your MySQL server tracks. The command helps you confirm existing databases before creating, dropping, or switching to one.
Run SHOW DATABASES;
in any MySQL client. The result set contains a single column named Database
listing all databases you have privileges to view.
Add a LIKE clause: SHOW DATABASES LIKE 'sales%';
. Wildcards let you narrow results to names that start, end, or contain a specific string.
Yes. Use SHOW DATABASES WHERE `Database` NOT LIKE '%test%';
for advanced filtering with logical operators, comparisons, or NOT clauses.
The list already respects your privileges. To confirm, connect as the intended user and re-run SHOW DATABASES;
. Databases outside your grants disappear from the result.
1) Always include a semicolon to terminate the statement. 2) Use precise patterns to avoid overlooking similarly named databases. 3) Combine SHOW DATABASES with USE db_name;
to switch quickly after inspection.
After restoring backups, run SHOW DATABASES;
to ensure the expected schemas exist before pointing applications to the new server.
No. You only need the SHOW DATABASES privilege or some privilege on at least one database. The output is limited to databases you can access.
Pattern matching obeys the server’s collation. On most installations it is case-insensitive, but always test on case-sensitive file systems.
No. SHOW DATABASES is a meta-command; its output column name is fixed as Database
. Wrap the statement in a subquery if you need a different alias.