Return list of databases in MySQL?

MySQLMySQLi Database

To return list of databases, the syntax is as follows −

select schema_name as anyAliasName from information_schema.schemata;

Here is the query to return list of databases in MySQL −

mysql> select schema_name as DatabaseName from information_schema.schemata;

This will produce the following output −

+---------------------------+
| DatabaseName              |
+---------------------------+
| mysql                     |
| information_schema        |
| performance_schema        |
| sys                       |
| business                  |
| sample                    |
| hello                     |
| test                      |
| mybusiness                |
| databasesample            |
| schemasample              |
| universitydatabase        |
| education                 |
| mydatabase                |
| database1                 |
| sampledatabase            |
| test3                     |
| javadatabase2             |
| javasampledatabase        |
| rdb                       |
| onetomanyrelationship     |
| webtracker                |
| web                       |
| commandline               |
| hb_student_tracker        |
| bothinnodbandmyisam       |
| customertracker           |
| tracker                   |
| demo                      |
| customer_tracker_database |
| login                     |
| onlinebookstore           |
| customer-tracker          |
| web_tracker               |
| instant_app               |
| 1233                      |
+---------------------------+
36 rows in set (0.00 sec)
raja
Published on 30-Dec-2019 06:31:27
Advertisements