获取 MySQL 数据库和版本列表?
要获得 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)
预告