How to Show the List of Databases in MySQL?
In MySQL, you can display the existing databases on a server with the SHOW DATABASES; statement. This is useful when you want to verify that a database was created, choose the correct database before running queries, or check which schemas are available to your current MySQL user.
This tutorial explains how to show databases in MySQL using the command-line interface and MySQL Workbench. It also covers filtering database names with LIKE, checking the currently selected database, understanding why some databases may not appear, and using SHOW SCHEMAS as an equivalent statement.
MySQL SHOW DATABASES Syntax
The basic syntax to list databases in MySQL is:
SHOW DATABASES;
MySQL also supports SHOW SCHEMAS;. In MySQL, a schema is treated as a database, so both statements return the same type of result.
SHOW SCHEMAS;
The result includes database names that your current MySQL account is allowed to see. If you do not have privileges on a database, it may not appear in the output even though it exists on the server.
| Task | MySQL command |
|---|---|
| Show all visible databases | SHOW DATABASES; |
| Show schemas using the equivalent statement | SHOW SCHEMAS; |
| Show database names matching a pattern | SHOW DATABASES LIKE 'school%'; |
| Show the currently selected database | SELECT DATABASE(); |
| Select a database for the session | USE database_name; |
Using the MySQL Command-Line Interface to SHOW DATABASES
The MySQL CLI provides a simple command to list all databases that are visible to your user account. Follow these steps:
Step 1: Connect to the MySQL Server
Open your terminal or command prompt and log in to the MySQL server using the following command:
mysql -u username -p
Replace username with your MySQL username. Enter your password when prompted to establish the connection.
In this guide, we will login to the server as root (username is root) as shown in the following screenshot.

If the server is remote, include the host name or IP address. For example:
mysql -h host_name -u username -p
Step 2: Show the List of Databases
Once logged in, execute the following SQL command to display all databases:
SHOW DATABASES;
This command will return a list of databases available on the server. For example:

Each row in the result represents a database. System databases like information_schema, performance_schema, and sys are typically included by default.
A simple text result from the MySQL shell may look like this:
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| school |
| sys |
+--------------------+
Step 3: Show Databases Matching a Name Pattern
When a MySQL server has many databases, filter the output with LIKE. The following statement shows only databases whose names start with school:
SHOW DATABASES LIKE 'school%';
A possible output is:
+--------------------+
| Database (school%) |
+--------------------+
| school |
| school_test |
+--------------------+
You can also use an exact name check when you want to confirm whether one database exists:
SHOW DATABASES LIKE 'school';
Step 4: Check the Currently Selected MySQL Database
SHOW DATABASES; lists available databases, but it does not select one. To check which database is currently selected for your session, run:
SELECT DATABASE();
If no database is selected, MySQL returns NULL. Select a database with the USE statement:
USE school;
After selecting it, run SELECT DATABASE(); again to verify the active database.
+------------+
| DATABASE() |
+------------+
| school |
+------------+
Step 5: Exit the MySQL Shell
To exit the MySQL CLI, type the following command:
exit;
This will close your connection to the MySQL server.
Show MySQL Databases Without Entering the Shell
You can run SHOW DATABASES; directly from the terminal with the -e option. This is useful in quick checks and scripts.
mysql -u username -p -e "SHOW DATABASES;"
After you enter the password, MySQL prints the database list and returns to the operating system prompt.
Using MySQL Workbench to SHOW DATABASES
MySQL Workbench provides a graphical interface for viewing the list of databases. In Workbench, databases are displayed under the Schemas panel.
Step 1: Launch MySQL Workbench
Open MySQL Workbench on your system and connect to the MySQL server by selecting the appropriate connection from the home screen.
Step 2: View the List of Databases in the Schemas Panel
After connecting, locate the “Schemas” panel on the left-hand side of the Workbench interface. This panel displays all available databases (schemas) on the connected server.

If the “Schemas” panel is not visible, click on the highlighted icon present in the top right corner.

If a database was created recently and does not appear immediately, right-click inside the Schemas panel and refresh the list.
Step 3: Execute SQL to List Databases
You can also run the SHOW DATABASES; command in the Query Editor to display the list of databases. To do this:
1. Open a new Query tab.
2. Enter the command SHOW DATABASES;.
3. Click on the execute button (lightning icon) to run the query.
The results will display in the output panel below.

You may also run the equivalent statement:
SHOW SCHEMAS;
Why SHOW DATABASES May Not List Every MySQL Database
If SHOW DATABASES; does not display a database that you expected to see, check permissions and connection details first. MySQL shows database names according to the privileges of the current user.
| Issue | Likely reason | What to check |
|---|---|---|
| A known database is missing from the result | Your MySQL user may not have privileges on that database. | Login with the correct account or ask the administrator to grant access. |
| Only system databases are visible | You may be connected as a limited user or connected to a fresh server. | Check the username and server connection. |
| The database appears in CLI but not in Workbench | Workbench may be connected to a different MySQL server or the schema list may need refresh. | Verify the connection host and refresh the Schemas panel. |
Access denied appears while connecting | The username, password, host, or authentication method is incorrect. | Check the login command and credentials. |
No database selected appears when running table queries | You listed databases but did not choose one for the session. | Run USE database_name; before creating or querying tables. |
System Databases Commonly Shown by MySQL
When you run SHOW DATABASES;, you may see some databases that were not created by you. These are system databases used by MySQL for metadata, privileges, performance information, and internal objects.
| Database name | Purpose |
|---|---|
information_schema | Provides metadata about databases, tables, columns, privileges, and other server objects. |
mysql | Stores system tables, including privilege and account-related information. |
performance_schema | Stores performance and instrumentation data when enabled. |
sys | Provides views and helper objects for easier access to performance and diagnostic information. |
Avoid modifying system databases unless you are following official administration steps and understand the effect of the change.
MySQL SHOW DATABASES Reference Links
For additional reference, see the official MySQL documentation for SHOW DATABASES and the MySQL manual section on getting information about databases and tables.
FAQs on Showing Existing Databases in MySQL
Which MySQL command shows existing databases?
The command is SHOW DATABASES;. It lists the databases that are visible to the current MySQL user account.
How do I display all databases from the MySQL command line?
Login with mysql -u username -p, enter the password, and run SHOW DATABASES;. To run it directly from the terminal, use mysql -u username -p -e "SHOW DATABASES;".
Why are some MySQL databases not shown by SHOW DATABASES?
MySQL may hide databases for which the current user has no privileges. Confirm that you are connected to the correct server and that your user account has access to the missing database.
Is SHOW SCHEMAS the same as SHOW DATABASES in MySQL?
Yes. In MySQL, SHOW SCHEMAS; is equivalent to SHOW DATABASES; and displays the same kind of database list.
How do I view the currently selected database in MySQL?
Run SELECT DATABASE();. If it returns NULL, no database is selected. Use USE database_name; to select one.
Editorial QA Checklist for This MySQL SHOW DATABASES Tutorial
- Confirms that
SHOW DATABASES;is the main MySQL statement for listing visible databases. - Explains that
SHOW SCHEMAS;is equivalent toSHOW DATABASES;in MySQL. - Shows both MySQL CLI and MySQL Workbench methods for viewing existing databases.
- Mentions that the database list depends on the privileges of the current MySQL user.
- Includes practical checks for filtering database names, selecting a database with
USE, and verifying the active database withSELECT DATABASE();.
TutorialKart.com