While working with MariaDB to manage databases in cPanel, the interfaces will be similar to that with MySQL. MariaDB is just made as a drop-in replacement for MySQL. In this tutorial we will see some commands using SSH for accessing the database and viewing it.
Steps to View MariaDB databases in SSH
1. Login to SSH.
2. Using the database user assigned to the database you want to view, login to MySQL (MariaDB). When the below command is executed, you will need to enter the MySQL user’s password.
MariaDB [(none)]> mysql -u username -p
If you are able to login successfully, you will see the below screen. Note that you see that you’re using MariaDB at this point.
3. You may find more than one database assigned to the user that you used to login to the mysql command line. So, select the database that will be used.
MariaDB [(none)]> show databases;
A list of databases that are assigned to the user name that you are using will get displayed.
4. Here you need to select your database. After selecting the database, your prompt will change to choose the database you have selected.
MariaDB [(none)]> use databasename;
5. Many commands are used in displaying the contents of a database. But here we will see just a few of them:
With the below command, a list of the tables from the database will get displayed.
MariaDB [arnel_test1]> show tables;
For seeing all the records in a specific table, use the below command:
MariaDB [arnel_test1]> select * from databasetablename;
For seeing all the database table field names, configuration and type of a certain table, use the below command:
MariaDB [arnel_test1]> describe databasetablename;
Note: For checking database specifics, it is needed to have a selected database with the USE command.
Congratulations you have learned to view a database using the command line in MariaDB.