How do I list databases in MySQL?

To list database type the following command

Open Terminal

mysql {PRESS ENTER}
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

quit {PRESS ENTER}
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

Say Hello

You can reach me by email, I'd love to hear from you.