Help Docs Server Administration Server Database Management MariaDB / MySQL Database Administration Show (List) MySQL Databases via Command Line on Linux

Show (List) MySQL Databases via Command Line on Linux

Find out how to easily show (list) all MySQL databases on Linux via command line with our comprehensive tutorial.

Introduction

This article explains how to list your MariaDB or MySQL databases, a fundamental skill for anyone working with MariaDB or MySQL. These instructions apply to both MariaDB and MySQL servers because MariaDB is a drop-in replacement for MySQL.

Listing your MySQL databases offers several key advantages, empowering you to better manage your data. Quickly seeing your list of databases can help you verify if the database you just created exists and is accessible. Reviewing your list of databases can help pinpoint whether the database itself is missing or if the issue lies elsewhere when troubleshooting database connection problems or data discrepancies.

Prerequisites

  • Root access.
  • MariaDB or MySQL installed. This process works the same on essentially all major Linux distributions.

Login to MariaDB / MySQL to List Databases

mysql command flags
-u root specifies the database user (root in this case).
-p tells MariaDB/MySQL to prompt you for the password.

  1. Log into the database server from the command line using the command below:
    mysql -u root -p
  2. Enter the root (or other database user) password when prompted.
  3. Verify your prompt after logging in, you should see one of the below prompts:
    • For MariaDB: 
      MariaDB [(none)]>
    • For MySQL:
      mysql>
  4. Show all databases by running the following command. (The same command works on both MariaDB and MySQL, producing similar results.)
    SHOW DATABASES;

    Example output:
    mysql> SHOW DATABASES;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | mysql              |
    | test               |
    +--------------------+
    4 rows in set (0.00 sec)
Special considerations for MariaDB users
MariaDB versions may include extra system databases, such as `performance_schema` or `sys`, depending on version and configuration. These are expected, and are needed for the system.

On some Linux distributions, MariaDB replaces MySQL entirely — running `mysql` in the terminal will still launch the MariaDB client.

Related Articles and Next Steps

Delete a database by following the instructions found here: Deleting a MySQL Database | Liquid Web

Was this article helpful?