How to View MariaDB Databases On Command Line

When you are working with MariaDB to manage databases in cPanel, you will be working with the same interfaces as you did when working with MySQL. MariaDB is made to be a drop-in replacement for MySQL. In this tutorial, we will be showing a few commands using SSH to view databases with MariaDB.

For those who prefer to work on the command line, this article will instruct you on how to list databases or view databases with MariaDB via the command line interface (or, CLI). For many database admins, this is the preferred way to access MariaDB databases. For a graphical interface, you can use PhpMyAdmin.

How To List Databases in MariaDB

First, log into your server via SSH. Then, you will use the same command to log into MariaDB as you would with MySQL:

mysql -u <username> -p

You will be prompted for a password. Note: be sure to replace <username> with your actual cPanel username or, if on VPS, the root user is also available to you.

You will now see your normal command prompt has turned into the MariaDB prompt:

SSH login

To properly list your databases, or show databases, you will just need to run the command:

SHOW DATABASES;
Show databases command

How To Use MariaDB To Work On a Database

You likely have a specific database in mind that you want to work with, in which case you will need to tell MariaDB which database you want to work on:

USE <databasename>;

Of course, replace <databasename> with the actual name of the database you want to use. If done correctly, you will see a notice that you have changed your database, and the MariaDB prompt will now print the name of the database in brackets:

Database changed
MariaDB [<databasename>]> 

How to View Tables in a MariaDB Database

To view the tables of a selected database, you can use the “show” command as follows:

SHOW tables;
show tables command

How to Show All The Records in a Table in MariaDB

At this point, you have instructed MariaDB to show all databases, selected a database, viewed tables, and now it’s time to show all of the records recorded in a certain table, which you can do with a “select” statement:

SELECT * FROM <databasetablename>

And be sure to replace <databasetablename> with the name of the table. This command will show all records.

Note: that in order to view database specifics, you will need to have selected a database with the USE command (see above). Then you can use the “describe” command to get more data about this table:

DESCRIBE <databasetablename>;

Well done! You know how to view databases and tables in MariaDB right from the command line interface.

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.

AC
Arnel Custodio Content Writer I

As a writer for InMotion Hosting, Arnel has always aimed to share helpful information and provide knowledge that will help solve problems and aid in achieving goals. He's also been active with WordPress local community groups and events since 2004.

More Articles by Arnel

2 thoughts on “How to View MariaDB Databases On Command Line

Was this article helpful? Join the conversation!