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;

Output:

+--------------------+
| 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.

Note
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;'