How to List Databases in MariaDB

Galaxy Glossary

How do I list all databases in MariaDB?

SHOW DATABASES returns the names of all databases the current user can access.

Sign up for the latest in SQL knowledge from the Galaxy Team!

Description

What does SHOW DATABASES do?

SHOW DATABASES lists every database the connected user has permission to see, making it the quickest way to discover existing schemas before running queries.

How do I list every database?

Run the simple statement SHOW DATABASES; in any SQL client or in Galaxy’s editor. The server returns one row per database.

How do I filter databases by name?

Add a LIKE or WHERE clause: SHOW DATABASES LIKE 'shop%'; limits the result set to names that begin with shop.

Can I sort the output?

MariaDB doesn’t support ORDER BY inside SHOW DATABASES. Copy the result into a subquery when ordering is required: SELECT * FROM (SHOW DATABASES) AS t ORDER BY Database;

How do I see only my ecommerce databases?

If your workspace contains customers, orders, and products databases, filter with LIKE: SHOW DATABASES LIKE '%orders%' OR LIKE '%products%';

What privileges are required?

You need the SHOW DATABASES privilege or any privilege on a database to see its name. DBAs can grant SHOW DATABASES ON *.* TO 'analyst'@'%';

When should I query INFORMATION_SCHEMA.SCHEMATA instead?

Use INFORMATION_SCHEMA.SCHEMATA when you need additional metadata such as default character set or collation. SELECT SCHEMA_NAME, DEFAULT_COLLATION_NAME FROM INFORMATION_SCHEMA.SCHEMATA;

Best practice tips

Prefix SHOW DATABASES with \\G in the MariaDB CLI to display each name on its own line. Avoid hard-coding database names—use SHOW DATABASES programmatically in admin scripts.

Why How to List Databases in MariaDB is important

How to List Databases in MariaDB Example Usage


-- Display all databases on the ecommerce server
SHOW DATABASES;

How to List Databases in MariaDB Syntax


SHOW {DATABASES | SCHEMAS}
    [LIKE 'pattern' | WHERE expr];

-- Example for an ecommerce server
SHOW DATABASES LIKE 'shop%';  -- returns shop, shop_test, shop_backup

Common Mistakes

Frequently Asked Questions (FAQs)

Is SHOW SCHEMAS the same as SHOW DATABASES?

Yes. MariaDB treats DATABASES and SCHEMAS as synonyms.

Does SHOW DATABASES include system databases?

Yes, you’ll see information_schema, mysql, and performance_schema unless your privileges hide them.

How can I list databases and their sizes?

Query INFORMATION_SCHEMA.SCHEMATA joined with TABLES: SELECT s.SCHEMA_NAME, SUM(t.DATA_LENGTH+t.INDEX_LENGTH) AS size_bytes FROM INFORMATION_SCHEMA.SCHEMATA s JOIN INFORMATION_SCHEMA.TABLES t ON s.SCHEMA_NAME=t.TABLE_SCHEMA GROUP BY 1;

Want to learn about other SQL terms?

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie
BauHealth Logo
Truvideo Logo