要获取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)