要获取MySQL数据库列表,以下是语法 -
show databases;
要获取服务器版本,您可以使用以下语法 -
select version();
让我们实现上述语法来获取MySQL数据库和版本的列表 -
mysql> show 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)
以下是获取版本的查询 -
mysql> select version();
这将产生以下输出 -
+-----------+
| version() |
+-----------+
| 8.0.12 |
+-----------+
1 row in set (0.00 sec)