In this article, we will learn how to get a list of all the databases in MySQL.
There are some ways to get the list of all the databases in MySQL. Here we are using these queries to get the list of all the databases on MySQL Workbench.
To get the list of all the database by using SHOW DATABASES
, a query is as follows:
SHOW DATABASES;
If you want to query the databases that match a specific pattern, then you use the LIKE
clause as follows:
SHOW DATABASES LIKE pattern;
SHOW DATABASES LIKE '%schema';
--skip-show-database
, you cannot use the SHOW DATABASES
statement unless you have the SHOW DATABASES
privilege.The SHOW SCHEMAS
statement is a synonym for SHOW DATABASES
, therefore the following statement returns the same result as the SHOW DATABASES
returns. To get the list of all the database by using SHOW SCHEMAS
, a query is as follows:
SHOW SCHEMAS;
To get the list of all the database by using INFORMATION_SCHEMA
, a query is as follows:
SELECT SCHEMA_NAME as DATABASE_NAME
FROM INFORMATION_SCHEMA.SCHEMATA
ORDER BY SCHEMA_NAME;
I hope this article will help you to understand how to get a list of all the databases in MySQL.
Share your valuable feedback, please post your comment at the bottom of this article. Thank you!
Comments