How to List MySQL Databases Using SHOW DATABASES

Want a list of MySQL databases? In this quick guide, I demonstrate how to show a list of databases in MySQL using SHOW DATABASES.

First, login as user root to your MySQL instance.

mysql -uroot -pYourPassword

Now that you are logged in, you simply need to run the SHOW DATABASES command.

SHOW DATABASES;

Produces the following list.

+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| test               |
+--------------------+

As I am logged in as root, I can see all databases. If you run this as another user, you will only see the databases that the user has access to.

You can also look for specific databases which is useful if your server contains many databases.

SHOW DATABASES LIKE 'mysql';
+------------------+
| Database (mysql) |
+------------------+
| mysql            |
+------------------+
1 row in set (0.00 sec)

Or you can use a wildcard to look for databases containing specific text.

SHOW DATABASES LIKE 'my%';
+----------------+
| Database (my%) |
+----------------+
| mysql          |
+----------------+
1 row in set (0.00 sec)

How to Show MySQL databases in MySQL Workbench

There are two ways, those listed above as seen here

mysql show databases

And you can also browse a list of available MySQL schemas but this does not include databases such as mysql or performance_schema

mysql list schemas

It's only fair to share...Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInPin on PinterestBuffer this pageShare on RedditShare on StumbleUpon
About Andy Hayes

Andy Hayes is a DBA working with SQL Server since version 7.0. He has a wonderful wife and two beautiful children. He loves database technology, playing cricket, and blogging. He is passionate about sharing his experiences as a DBA and learning more to further his understanding and knowledge. You can follow me on Twitter, check out my Facebook page or follow me on

Speak Your Mind

*


*