Listing databases in MySQL or MariaDB provides a quick inventory of schemas available to an account before running migrations, granting privileges, or pointing an application at the right server.
The server treats “database” and “schema” as synonyms and stores the names in its internal data dictionary. The mysql client (or mariadb on some systems) sends SQL to the server, and SHOW DATABASES returns a result set that is filtered by privileges unless the account has the global SHOW DATABASES privilege.
System schemas such as information_schema, mysql, performance_schema, and sometimes sys often appear alongside application schemas. Connection details (host, port, authentication plugin, and TLS requirements) determine whether the client can log in, so listing databases is most reliable after a known-good login using an account intended for administration or automation.
$ mysql --host db.example.net --port 3306 --user dbadmin --password Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 20 Server version: 8.0.44 MySQL Community Server - GPL Copyright (c) 2000, 2025, Oracle and/or its affiliates. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
Avoid --password=secret because credentials can be exposed via process listings and shell history.
For a local Unix socket connection, omit –host and –port:
$ mysql --user dbadmin --password
mysql> SHOW DATABASES; +--------------------+ | Database | +--------------------+ | analytics | | app | | appdb | | archive | | employees | | information_schema | | inventory | | myapp | | mysql | | performance_schema | | reporting | | shop | | sys | | testdb | +--------------------+ 14 rows in set (0.00 sec)
The result is privilege-scoped unless the account has the global SHOW DATABASES privilege.
In the interactive client, terminate statements with ; to execute them.
mysql> SHOW DATABASES LIKE 'app%'; +-----------------+ | Database (app%) | +-----------------+ | app | | appdb | +-----------------+ 2 rows in set (0.00 sec)
In LIKE patterns, '%' matches any length and '_' matches a single character.
mysql> SHOW DATABASES WHERE `Database` NOT IN ('information_schema','mysql','performance_schema','sys');
+-----------+
| Database |
+-----------+
| analytics |
| app |
| appdb |
| archive |
| employees |
| inventory |
| myapp |
| reporting |
| shop |
| testdb |
+-----------+
10 rows in set (0.00 sec)
mysql> SHOW DATABASES LIKE 'reporting'; +----------------------+ | Database (reporting) | +----------------------+ | reporting | +----------------------+ 1 row in set (0.00 sec)
An empty result indicates the database name is not present or not visible to the account.
mysql> USE reporting; Database changed
An access error indicates missing privileges on the selected database.
mysql> SELECT DATABASE(); +------------+ | DATABASE() | +------------+ | reporting | +------------+ 1 row in set (0.00 sec)
mysql> exit Bye