Show (List) MySQL Databases on Linux via Command Line

Reading Time: < 1 minute

Pre-Flight Check

  • These instructions are intended for showing (listing) all MySQL databases via the command line.
  • I’ll be working from a Liquid Web Core Managed CentOS 7 server, and I’ll be logged in as root.

show databases via cli

Login to MySQL

First we’ll login to the MySQL server from the command line with the following command:

mysql -u root -p

In this case, I’ve specified the user root with the -u flag, and then used the -p flag so MySQL prompts for a password. Enter your current root password to complete the login.

If you need to change your root (or any other) password in the database, then follow this tutorial on changing a password for MySQL via the command line.

You should now be at a MySQL prompt that looks very similar to:

mysql>

or

MariaDB [(none)]>

Show (View) All MySQL Databases

To view the database you’ve created simply issue the following command:

SHOW DATABASES;

Your result should be similar to this:

mysql> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| test               |
+--------------------+
4 rows in set (0.00 sec)

Would you like to create a new database? Check out our tutorial: Create a MySQL Database on Linux via Command Line

Avatar for Justin Palmer

About the Author: Justin Palmer

Justin Palmer is a professional application developer with Liquid Web

Latest Articles

How to Upload Information to VMware through SFTP

Read Article

Accessing Man Pages on Ubuntu 16.04 LTS

Read Article

TLS vs SSL: A Comparison

Read Article

Premium Business Email Pricing FAQ

Read Article

Microsoft Exchange Server Security Update

Read Article