当前位置:网站首页>How to display all MySQL databases
How to display all MySQL databases
2022-06-29 04:22:00 【Yisu cloud】
How to display all MySQL database
This article introduces in detail “ How to display all MySQL database ”, Detailed content , The steps are clear , The details are handled properly , Hope this article “ How to display all MySQL database ” The article can help you solve your doubts , Let's follow Xiaobian's ideas and go deeper slowly , Let's learn new knowledge together .
database It can be regarded as a container for storing data objects , Each database has a unique name , And the name of the database is meaningful , In this way, you can clearly see what data each database is used to store . stay MySQL There are system database and user-defined database in the database , The system database is installed MySQL After the system comes with the database , A custom database is a database created by user definition .

Show MySQL database
obtain MySQL The most common way to list databases is to use mysql The client connects to MySQL The server And run SHOW DATABASES command .
Use the following command to access MySQL The server , And enter your... When prompted MySQL User password :
mysql -u user -p
*
If you have not yet done so for MySQL User set password , You can omit this
-pswitch .
stay MySQL shell Execute the following command in :
SHOW DATABASES;
This command will print a list of all databases for which the user has permissions . The output will be similar to :
+--------------------+ | Database | +--------------------+ | information_schema | | opencart | +--------------------+ 2 rows in set (0.00 sec)
SHOW SCHEMAS Is another command that can be used to list databases , It is SHOW DATABASES Synonyms for commands :
SHOW SCHEMAS;
Output and use SHOW DATABASES The output of the command is the same :
+--------------------+ | Database | +--------------------+ | information_schema | | opencart | +--------------------+ 2 rows in set (0.00 sec)
Show all MySQL database
To list MySQL All databases on the server , You need to log in as a user who has access to all databases , By default root The user has the permission to view all databases . Able to use SHOW DATABASES List all databases .
Use root The user login MySQL:
mysql -u root -p
function SHOW DATABASES command :
SHOW DATABASES;
You will see MySQL List of all databases on the server :

+--------------------+ | Databases | +--------------------+ | information_schema | | database_name | | mysql | | opencart | | wordpress | | performance_schema | | sys | +--------------------+ 7 rows in set (0.00 sec)
Filter results
If the output of the command is filtered according to a specific mode , Please run SHOW DATABASES When you use LIKE Clause .
SHOW DATABASES LIKE pattern;
for example , The following statement returns the name with “open” All the databases at the beginning :
SHOW DATABASES LIKE 'open%'; +--------------------+ | Database | +--------------------+ | opencart | +--------------------+ 1 rows in set (0.00 sec)
*
Percent sign (
%) Represents zero , One or more characters .
If you want to do a more complex search , It can be downloaded from information_schema In the database schemata Query in the table according to conditions .
The following statement will provide you with the “open” or “word” List of all databases at the beginning :
SELECT schema_name FROM information_schema.schemata WHERE schema_name LIKE 'open%' OR schema_name LIKE 'word%'; +--------------------+ | Database | +--------------------+ | opencart | | wordpress | +--------------------+ 2 rows in set (0.00 sec)
Display... From the command line MySQL database
To log in without MySQL shell To get the database list , You can use mysql The order carries -e Options ( representative execute), You can also use mysqlshow Commands to display database and table information .
When you want to use shell Script use MySQL Database time , This is especially useful .
Run the following command on the terminal to display a list of all databases :
mysql -u user -p -e 'show databases;'+--------------------+ | Database | +--------------------+ | information_schema | | opencart | +--------------------+
Here's how to use the mysqlshow Examples of commands :
mysqlshow -u user -p
The output will be the same as in the previous command .
If you want to filter the output , have access to grep command .
Read here , This article “ How to display all MySQL database ” The article has been introduced , If you want to master the knowledge points of this article, you need to practice and use it yourself to understand , If you want to know more about this article , Welcome to the Yisu cloud industry information channel .
边栏推荐
- Call snapstateon closed sou from Oracle CDC
- CDC2.2.1还不支持postgresql14.1么?基于pgbouncer连接方式下,以5433
- Blue Bridge Cup DFS (I)
- lua-protobuff emmy-lua 轮子
- The second meeting of the Second Council of Euler open source community was held, and Xinhua III, hyperfusion and Godson Zhongke became members of the Council
- ECS 四 Sync Point、Write Group、Version Number
- 从零到一,教你搭建「以文搜图」搜索服务(一)
- Why is the test post a giant pit? The 8-year-old tester told you not to be fooled
- How to merge upstream and downstream SQL data records
- Practical part: solving the function conflict between swagger and user-defined parameter parser
猜你喜欢

Cloud native weekly | grafana 9 was officially released; The Chinese version of cloud native vocabulary is now online

Ask a simple question about SQL

SEAttention 通道注意力机制

Anaconda自带的Spyder编辑器启动报错问题

JDBC learning

sql两列变为多行过滤显示

从零到一,教你搭建「以文搜图」搜索服务(一)

如何创建 robots.txt 文件?

New listing of operation light 3.0 -- a sincere work of self subversion across the times

Runtimeerror in yolox: dataloader worker (PID (s) 17724, 1364, 18928) exited unexpectedly
随机推荐
[laravel series 8] out of the world of laravel
SQL database stored procedure writing method
Ansible最佳实践之Playbook不同上下文提权Demo
Implementation of thread pool based on variable parameter template
Binary tree serialization and deserialization (leetcode (difficult))
SQL two columns become multi row filter display
How sqlserver queries and removes results with null fields in the whole column
Here comes Wi Fi 7. How strong is it?
On June 27, 2022, I have the right to choose the journey of the summer vacation.
JVM_ 16_ Garbage collector
【HackTheBox】dancing(SMB)
Apifox: it is not only an API debugging tool, but also a collaboration artifact of the development team
How to create robots Txt file?
Basic use of JSX
webassembly学习-动态链接
iNFTnews | 元宇宙技术将带来全新的购物体验
访问数据库时出现错误
Anaconda's own Spyder editor starts with an error
干货丨微服务架构是什么?有哪些优点和不足?
Libuv library overview and comparison of libevent, libev and libuv (Reprint)