当前位置: 首页 > MySQL数据库

mysql如何查询所有数据库

时间:2026-01-28 14:09:54

本教程操作环境:windows7系统、mysql8版本、Dell G3电脑。

要列出MySQL服务器主机上的所有数据库,请使用SHOW DATABASES命令,如下所示:

SHOW DATABASES;

例如,要列出本地MySQL数据库服务器中的所有数据库,请首先登录到数据库服务器,如下所示:

C:\Users\Administrator>mysql -u root -pEnter password: ******Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 7Server version: 5.7.9 MySQL Community Server (GPL)Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>

然后使用SHOW DATABASES命令:

mysql> SHOW DATABASES;+--------------------+| Database           |+--------------------+| information_schema || crmdb              || mysql              || newdb              || performance_schema || testdb             || yiibaidb           || yiibaidb_backup    |+--------------------+8 rows in set

SHOW SCHEMAS命令是SHOW DATABASES的同义词,因此以下命令将返回与上述相同的结果:

mysql> SHOW SCHEMAS;+--------------------+| Database           |+--------------------+| information_schema || crmdb              || mysql              || newdb              || performance_schema || testdb             || yiibaidb           || yiibaidb_backup    |+--------------------+8 rows in set

如果要查询与特定模式匹配的数据库,请使用LIKE子句,如下所示:

SHOW DATABASES LIKE pattern;

例如,以下语句返回以字符串“schema”结尾的数据库;

mysql> SHOW DATABASES LIKE '%schema';+--------------------+| Database (%schema) |+--------------------+| information_schema || performance_schema |+--------------------+2 rows in set

重要的是要注意,如果MySQL数据库服务器以-skip-show-database启动,则除非具有SHOW DATABASES权限,否则不能使用SHOW DATABASES语句。


上一篇:MySQL不再支持Berkeley DB 转而添加插件的示例分析
下一篇:mysql删库语句怎么写
mysql 数据库
  • 英特尔与 Vertiv 合作开发液冷 AI 处理器
  • 英特尔第五代 Xeon CPU 来了:详细信息和行业反应
  • 由于云计算放缓引发扩张担忧,甲骨文股价暴跌
  • Web开发状况报告详细介绍可组合架构的优点
  • 如何使用 PowerShell 的 Get-Date Cmdlet 创建时间戳
  • 美光在数据中心需求增长后给出了强有力的预测
  • 2027服务器市场价值将接近1960亿美元
  • 生成式人工智能的下一步是什么?
  • 分享在外部存储上安装Ubuntu的5种方法技巧
  • 全球数据中心发展的关键考虑因素
  • 英特尔与 Vertiv 合作开发液冷 AI 处理器

    英特尔第五代 Xeon CPU 来了:详细信息和行业反应

    由于云计算放缓引发扩张担忧,甲骨文股价暴跌

    Web开发状况报告详细介绍可组合架构的优点

    如何使用 PowerShell 的 Get-Date Cmdlet 创建时间戳

    美光在数据中心需求增长后给出了强有力的预测

    2027服务器市场价值将接近1960亿美元

    生成式人工智能的下一步是什么?

    分享在外部存储上安装Ubuntu的5种方法技巧

    全球数据中心发展的关键考虑因素