To get the MySQL database list, following is the syntax -
show databases;
To get the server version, you can use the following syntax -
select version();
Let’s implement it The above syntax to get the list of MySQL databases and versions -
mysql> show databases;
This will produce the following output showing 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)
Here is the query to get the versions -
mysql> select version();
This will produce the following output -
+-----------+ | version() | +-----------+ | 8.0.12 | +-----------+ 1 row in set (0.00 sec)
The above is the detailed content of Get a list of MySQL databases and versions?. For more information, please follow other related articles on the PHP Chinese website!