MySQL - List Databases

This article will walk you through listing the databases that are running in MySQL.


First thing is to log into your Server via the terminal or PuTTY, etc and then log into MySQL:

mysql -u root -p

You will be prompted for your MySQL root password (note this is not the same as the Server root password).

Show databases

Do note that all MySQL commands must end in a semi-colon (;) so that it knows that is the end of the command and to execute it.

We want to show the databases and the command is simply:

SHOW databases;

The command does not have to be in capitals - I use capitals for clarity.

On my test Server running Ubuntu Hardy the output is as follows:

mysql> SHOW databases;
| Database           |
| information_schema | 
| mysql              | 
2 rows in set (0.00 sec)

As you can see, the default installation on Ubuntu Hardy has two databases: information_schema and mysql.

Both are required for the base running of MySQL and should not be adjusted by hand.

If you are using a different distribution you may see a third database called 'test' which should be deleted as soon as possible.

Was this content helpful?

© 2015 Rackspace US, Inc.

Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License

See license specifics and DISCLAIMER