Get a list of MySQL databases and version?

MySQLMySQLi Database

To get a list of MySQL databases, following is the syntax -

show databases;

To get the server version, you can use the below syntax -

select version();

Let us implement the above syntax to get a list of MySQL databases and version -

mysql> show databases;

This will produce the following output displaying all the databases -

+---------------------------+
| Database                  |
+---------------------------+
| bothinnodbandmyisam       |
| business                  |
| commandline               |
| customer-tracker          |
| customer_tracker_database |
| customertracker           |
| database1                 |
| databasesample            |
| demo                      |
| education                 |
| hb_student_tracker        |
| hello                     |
| information_schema        |
| instant_app               |
| javadatabase2             |
| javasampledatabase        |
| login                     |
| mybusiness                |
| mydatabase                |
| mysql                     |
| onetomanyrelationship     |
| onlinebookstore           |
| performance_schema        |
| rdb                       |
| sample                    |
| sampledatabase            |
| schemasample              |
| slotgame                  |
| sys                       |
| test                      |
| test3                     |
| tracker                   |
| universitydatabase        |
| web                       |
| web_tracker               |
| webtracker                |
+---------------------------+
36 rows in set (0.00 sec)

Following is the query to get version -

mysql> select version();

This will produce the following output -

+-----------+
| version() |
+-----------+
| 8.0.12    |
+-----------+
1 row in set (0.00 sec)
raja
Published on 21-Aug-2019 15:06:21
Advertisements