SHOW DATABASES
Open the client as an administrative user. On Ubuntu and Debian that is usually:
sudo mysql
Where root has a password, use mysql -u root -p and type the password at the prompt, never on the command line. Then:
SHOW DATABASES;
SHOW SCHEMAS; is the same command under another name. In MySQL, a schema and a database are the same thing.
The System Databases
A new server already lists several databases. Do not drop or edit them:
| Database | What it holds |
|---|---|
mysql | Accounts, privileges, settings |
information_schema | Read-only metadata |
performance_schema | Runtime statistics |
sys | Views over those statistics |
MariaDB shows a similar set. Everything else was created by you or by an application.
Filter the List
SHOW DATABASES LIKE 'shop%';
% matches any run of characters and _ matches one character. Since _ is a wildcard, LIKE 'shop_db' also matches shopXdb; write shop\_db to match the underscore only.
From the Shell
sudo mysql -e "SHOW DATABASES;"
sudo mysql -N -B -e "SHOW DATABASES;"
The second form drops the header and the table borders and prints one name per line, which suits scripts. A loop over the names, for example to dump each database, is shown in the bash for loop guide.
The mysqlshow tool lists databases too, and the tables of one database when you name it:
sudo mysqlshow
sudo mysqlshow app
On MariaDB the tool is named mariadb-show.
Why a Database Is Missing
SHOW DATABASES lists only databases on which your account has some privilege. An application account that was granted rights on app.* sees app and information_schema and nothing else. That is the intended setup, not an error. An account with the global SHOW DATABASES privilege sees all names.
If the administrator also misses a database, check that you are connected to the server you think you are. The status command in the client shows the server and the connection.
Database Sizes in One Query
SELECT table_schema AS db,
ROUND(SUM(data_length + index_length) / 1024 / 1024, 1) AS size_mb
FROM information_schema.tables
GROUP BY table_schema
ORDER BY size_mb DESC;
The figures are estimates the storage engine reports. MySQL 8.0 and later cache them for up to 24 hours by default (the information_schema_stats_expiry setting, 86400 seconds); ANALYZE TABLE refreshes the figures of one table. They are close enough to see which database grows. For the space on disk itself, look at /var/lib/mysql as described in how to check disk space in Linux.
Tables Inside a Database
USE app;
SHOW TABLES;
SHOW TABLES FROM app;
SHOW TABLE STATUS FROM app;
SHOW TABLE STATUS adds the engine, row estimate, and size of each table.
The same list of databases is also a table you can query, which helps when you need a condition that LIKE cannot express, or the default character set of each database:
SELECT schema_name, default_character_set_name
FROM information_schema.schemata;
Create and Drop
CREATE DATABASE app CHARACTER SET utf8mb4;
Dropping a database deletes all its tables at once, and there is no undo. Take a dump first and check the name twice:
DROP DATABASE old_app;
To see who may use a database, see how to list users in MySQL.