13.7.7.14 SHOW DATABASES Statement语句

SHOW {DATABASES | SCHEMAS}
    [LIKE 'pattern' | WHERE expr]

SHOW DATABASES lists the databases on the MySQL server host. SHOW DATABASES列出了MySQL服务器主机上的数据库。SHOW SCHEMAS is a synonym for SHOW DATABASES. SHOW SCHEMASSHOW DATABASES的同义词。The LIKE clause, if present, indicates which database names to match. LIKE子句(如果存在)指示要匹配的数据库名称。The WHERE clause can be given to select rows using more general conditions, as discussed in Section 26.8, “Extensions to SHOW Statements”.WHERE子句可以用于使用更通用的条件来选择行,如第26.8节,“SHOW语句的扩展”所述。

You see only those databases for which you have some kind of privilege, unless you have the global SHOW DATABASES privilege. 除非您具有全局SHOW DATABASES权限,否则您只能看到那些具有某种权限的数据库。You can also get this list using the mysqlshow command.您也可以使用mysqlshow命令获取此列表。

If the server was started with the --skip-show-database option, you cannot use this statement at all unless you have the SHOW DATABASES privilege.如果服务器是使用--skip-show-database选项启动的,则除非您具有SHOWS DATABASES权限,否则根本无法使用此语句。

MySQL implements databases as directories in the data directory, so this statement simply lists directories in that location. However, the output may include names of directories that do not correspond to actual databases.MySQL将数据库实现为数据目录中的目录,因此此语句只列出该位置的目录。但是,输出可能包括与实际数据库不对应的目录名称。

Database information is also available from the INFORMATION_SCHEMA SCHEMATA table. 数据库信息也可从INFORMATION_SCHEMA SCHEMATA表中获得。See Section 26.3.31, “The INFORMATION_SCHEMA SCHEMATA Table”.请参阅第26.3.31节,“INFORMATION_SCHEMA SCHETA表”

Caution小心

Because any static global privilege is considered a privilege for all databases, any static global privilege enables a user to see all database names with SHOW DATABASES or by examining the SCHEMATA table of INFORMATION_SCHEMA, except databases that have been restricted at the database level by partial revokes.由于任何静态全局特权都被视为所有数据库的特权,因此任何静态全局权限都允许用户使用SHOW DATABASES或通过检查INFORMATION_SCHEMASCHEMATA表来查看所有数据库名称,但在数据库级别受到部分吊销限制的数据库除外。