SQL Command to List & Show All Databases in MySQL & MariaDB

»»»SQL Command to List & Show All Databases in MySQL & MariaDB
mysql is a simple and easy to use SQL shell with input line editing capabilities that supports interactive and noninteractive use. The hard part of using mysql is that the administrator needs to remember the SQL command syntax to connect, manage and use the databases.

This tutorial shows how you can show the list of databases on MySQL or MariaDB servers using mysql client.

To invoke mysql command-line SQL shell, type:

$ mysql --user=user-name --password=password
If you want to connect to MySQL or MariaDB servers remotely on another server, append -h server-name-or-IP-address to the command.

To list all databases running on the server, type the following command:

mysql> show databases;


| Database           |
| information_schema |
| techjourny         |
| mysql              |
| test               |
| performance_schema |
5 rows in set (0.27 sec)

That’s it. It’s so simple. You can use the database you want to perform SQL queries on it.

From shell command line, you can use the following one liner to get the databases information directly:

$ mysql --user=user-name --password=password -e 'show databases;'

By |2016-12-09T08:38:23+00:00December 9th, 2016|Categories: Databases|Tags: , |0 Comments

About the Author:

LK is a technology writer for Tech Journey with background of system and network administrator. He has be documenting his experiences in digital and technology world for over 15 years.Connect with LK through Tech Journey on Facebook, Twitter or Google+.