Join my Laravel for REST API's course on Udemy 👀

Show all databases in your MySQL database

December 30, 2020  ‐ 1 min read

The most common way to show the databases on your system is by using the SHOW DATABASES statement. This shows a list of all databases that your database user has access to.

So in my case there are databases showing up which MySQL uses for internal use. Like for managing users and privileges for example.

mysql> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| production         |
| staging            |
| sys                |
+--------------------+
6 rows in set
Time: 0.029s

The SHOW SCHEMAS statement is a synonym for SHOW DATABASES. So you might as well use that, it is shorter to type :).

You can if you need to pass a pattern to this query as well. To filter out some of the resulting rows you'll get.

SHOW DATABASES LIKE '%schema';
+--------------------+
| Database (%schema) |
+--------------------+
| information_schema |
| performance_schema |
+--------------------+
2 rows in set
Time: 0.018s