Get the App
SLTechnology News&Howtos  ›  Database  › 

How does mysql query all databases

Shulou Source: shulou.com Published: 2022-05-31 12:41:02 09月21日 Update

This article mainly introduces mysql how to query all databases, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

Mysql query all databases: 1, use the MySQL client to log in to the MySQL database server; 2, directly execute the "SHOW DATABASES;" or "SHOW SCHEMAS;" command to list all databases.

The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.

"to list all databases on the MySQL server host, use the SHOW DATABASES command, as follows:"

SHOW DATABASES

For example, to list all the databases in the local MySQL database server, log in to the database server first, as follows:

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 >

Then use the SHOW DATABASES command:

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

The SHOW SCHEMAS command is synonymous with SHOW DATABASES, so the following command returns the same result as above:

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

If you want to query a database that matches a specific pattern, use the LIKE clause, as follows:

SHOW DATABASES LIKE pattern

For example, the following statement returns a database that ends with the string "schema"

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

It is important to note that if the MySQL database server is started with-skip-show-database, you cannot use the SHOW DATABASES statement unless you have SHOW DATABASES permission.

Thank you for reading this article carefully. I hope the article "how to query all databases in mysql" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Data database command server service query article statement login same important host value interest synonym simultaneously clause character string customer Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple MariaDB Linux MySQL Microsoft