mysql怎么查询所有数据库
1、使用MySQL客户端登录到MySQL数据库服务器;
2、直接执行“SHOW DATABASES;”或“SHOW SCHEMAS;”命令即可列出所有数据库。
要列出MySQL服务器主机上的所有数据库,请使用SHOW DATABASES命令,如下所示:
SHOW DATABASES;
例如,要列出本地MySQL数据库服务器中的所有数据库,请首先登录到数据库服务器,如下所示:
C:\Users\Administrator>mysql -u root -p
Enter password: ******
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server 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 its
affiliates. Other names may be trademarks of their respective
owners.
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
如果要查询与特定模式匹配的数据库,请使用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语句。
声明:本站(www.mysqlschool.cn)所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。