X

How to View MariaDB Databases Using the Command Line

How to List Databases in MariaDB
List Databases in MariaDB

MariaDB is a drop-in replacement for MySQL, meaning you can use the same commands to manage databases. If you prefer working from the command line instead of using a graphical interface like phpMyAdmin, this guide will show you how to list databases, select a database, view tables, and display records using MariaDB commands in SSH.

For a graphical interface, you can use PhpMyAdmin.

How To List Databases in MariaDB

First, log into your server via SSH. Then, access MariaDB using the following command:

mysql -u <username> -p

Replace <username> with your actual cPanel username. If you are using a VPS or dedicated server, you can log in as the root user. After entering the command, you will be prompted to enter your database password.

Once logged in, your command prompt will change to the MariaDB prompt.

To list all available databases, run:

SHOW DATABASES;

This will display a list of all databases associated with your account.

How to Select a Database in MariaDB

If you want to work with a specific database, you need to select it using the following command:

USE <databasename>;

Replace <databasename> with the actual name of your database. If successful, you will see a confirmation message:

Database changed
MariaDB [<databasename>]> 

How to View Tables in a MariaDB Database

After selecting a database, you can view all the tables within it by running:

SHOW TABLES;

How to Display Records in a Table

To view all records within a specific table, use the following query:

SELECT * FROM <tablename>;

Replace <tablename> with the actual name of the table you want to view. This will display all records stored in that table.

If you need more details about the table’s structure, you can use:

DESCRIBE <databasetablename>;

This will show column names, data types, and additional information about the table’s structure.

Final Thoughts

Now you know how to access MariaDB via SSH, list databases, select a database, view tables, and retrieve records using simple command-line queries. This method provides a fast and efficient way to manage databases, especially for those who prefer working in a terminal environment.

For developers or sysadmins experienced with the command line, get high availability and root access for your application, service, and websites with Cloud VPS Hosting.

Derrell Willis
Derrell Willis Manager, Developer Relations

More Articles by Derrell

2 thoughts on “How to View MariaDB Databases Using the Command Line

Was this article helpful? Join the conversation!