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:

</>
Copy
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.

</>
Copy
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.

TaskMySQL command
Show all visible databasesSHOW DATABASES;
Show schemas using the equivalent statementSHOW SCHEMAS;
Show database names matching a patternSHOW DATABASES LIKE 'school%';
Show the currently selected databaseSELECT DATABASE();
Select a database for the sessionUSE 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:

</>
Copy
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.

Connect to the MySQL Server

If the server is remote, include the host name or IP address. For example:

</>
Copy
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:

</>
Copy
SHOW DATABASES;

This command will return a list of databases available on the server. For example:

Show Databases in MySQL

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:

</>
Copy
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:

</>
Copy
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:

</>
Copy
SELECT DATABASE();

If no database is selected, MySQL returns NULL. Select a database with the USE statement:

</>
Copy
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:

</>
Copy
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.

</>
Copy
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:

</>
Copy
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.

IssueLikely reasonWhat to check
A known database is missing from the resultYour 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 visibleYou 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 WorkbenchWorkbench 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 connectingThe username, password, host, or authentication method is incorrect.Check the login command and credentials.
No database selected appears when running table queriesYou 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 namePurpose
information_schemaProvides metadata about databases, tables, columns, privileges, and other server objects.
mysqlStores system tables, including privilege and account-related information.
performance_schemaStores performance and instrumentation data when enabled.
sysProvides 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 to SHOW 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 with SELECT DATABASE();.