Show (List) MySQL Databases via Command Line on Linux
What to Know Before Listing MySQL Databases — 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.
![List MySQL Databases via Command Line](https://res.cloudinary.com/lwgatsby/f_auto/www/uploads/2020/03/how.to_.show_.mysql_.db_.on_.cli_.3.5.20.jpg)
Login to MySQL to List Databases
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 (List) All MySQL Databases via the Command Line
To view in a list 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.
Related Articles:
![Avatar for Justin Palmer](/static/d4d2e9dbcba27afb3125497f12b4cd97/9ca7a/26385c65e8b82bf2d9c0e617d20807e7.png)
About the Author: Justin Palmer
Justin Palmer is a professional application developer with Liquid Web
Our Sales and Support teams are available 24 hours by phone or e-mail to assist.
Latest Articles
How to install PyTorch on Linux (AlmaLinux)
Read ArticleInnovative armor — exploring ThreatDown’s impact on cyber defense
Read ArticleControlling PHP settings with a custom php.ini file
Read ArticleLinux dos2unix command syntax — removing hidden Windows characters from files
Read ArticleChange cPanel password from WebHost Manager (WHM)
Read Article