SHOW DATABASES lists the databases on the server that your account is allowed to see.
CREATE DATABASE shop;
CREATE DATABASE blog;
SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| blog |
| information_schema |
| learn |
| mysql |
| performance_schema |
| shop |
| sys |
+--------------------+
7 rows in set
You see your own databases, learn, shop and blog, and four built-in ones: information_schema, mysql, performance_schema and sys. The System Databases lesson explains them.
Filter the list
LIKE uses wildcards: % for any text, _ for one character.
SHOW DATABASES LIKE 's%';
+---------------+
| Database (s%) |
+---------------+
| shop |
| sys |
+---------------+
2 rows in set
WHERE accepts a full condition on the column Database:
SHOW DATABASES WHERE `Database` NOT IN ('information_schema', 'mysql', 'performance_schema', 'sys');
+----------+
| Database |
+----------+
| blog |
| learn |
| shop |
+----------+
3 rows in set
The standard-SQL way
SHOW DATABASES is MySQL syntax. The portable way uses INFORMATION_SCHEMA, which works like any table and can be sorted, joined and filtered:
SELECT schema_name, default_character_set_name, default_collation_name
FROM information_schema.schemata
WHERE schema_name IN ('shop', 'blog')
ORDER BY schema_name;
+-------------+----------------------------+------------------------+
| SCHEMA_NAME | DEFAULT_CHARACTER_SET_NAME | DEFAULT_COLLATION_NAME |
+-------------+----------------------------+------------------------+
| blog | utf8mb4 | utf8mb4_0900_ai_ci |
| shop | utf8mb4 | utf8mb4_0900_ai_ci |
+-------------+----------------------------+------------------------+
2 rows in set
You only see what you may see
An account without privileges on a database does not see it in the list. If your user cannot see a database you know exists, it is a permission issue, not a missing database.
SELECT COUNT(*) AS visible_databases FROM information_schema.schemata;
+-------------------+
| visible_databases |
+-------------------+
| 7 |
+-------------------+
1 row in set
In scripts
information_schema.schemata. To create it safely, use CREATE DATABASE IF NOT EXISTS.