How do I list databases in MySQL?

To list database type the following command

Open Terminal

mysql> show databases;

This is the output of my command, it only listed the mysql default database, not quite what I wanted to see.

| Database           |
| information_schema |
| test               |

The reason my databases weren’t listed is because I wasn’t logged in as root so when logging in I typed -u root and if you have a password you’ll have to do that by adding -p yourpassword

mysql -u root {PRESS ENTER}
mysql> show databases; {PRESS ENTER}

| Database                 |
| information_schema       |
| headliner            |
| mysql                    |
| test                     |

Now I’m able to see all databases that I’ve installed.

Back to Blog