当前位置:网站首页>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 .
边栏推荐
- 科班出身,结果外包都不要
- Libuv库概述及libevent、libev、libuv对比(转载)
- I came from a major, so I didn't want to outsource
- Apifox : 不仅是Api调试工具,更是开发团队的协作神器
- How to keep database and cache consistent
- Error accessing database
- Nuxt - set SEO related tags, page titles, icons, etc. separately for each page (page configuration head)
- If you choose the right school, you can enter Huawei as a junior college. I wish I had known
- Inftnews | metauniverse technology will bring a new shopping experience
- 项目开发修养
猜你喜欢

How sqlserver queries and removes results with null fields in the whole column

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

LabVIEW displays Unicode characters

Why is the test post a giant pit? The 8-year-old tester told you not to be fooled

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

直播预约|AWS Data Everywhere 系列活动
![[new function] ambire wallet integrates Metis network](/img/29/8a8c0cd40c51cef1174ee59706d4c9.png)
[new function] ambire wallet integrates Metis network

moudo网络库剖析

iNFTnews | 元宇宙技术将带来全新的购物体验

How to merge upstream and downstream SQL data records
随机推荐
ROS URDF model is parsed into KDL tree
1017 a divided by B
044. (2.13) add value to yourself
Remote connection of raspberry pie in VNC Viewer Mode
Ling Jing thinks about her own way
Redis cache penetration, cache breakdown, cache avalanche
Remediation for Unsafe Cryptographic Encryption
Five thousand years of China
使用AssetStudio/UnityStudio UABE等
sql数据库存储过程写法
Anaconda's own Spyder editor starts with an error
选对学校,专科也能进华为~早知道就好了
Installation and configuration of interrealsense d435i camera driver
c语言 --- 分支结构
SQL 数据记录如何上下行合并
大神们 在富函数的open中从mysql连接池里取连接 连接池初始化是20个 如果富函数的并行度是1
赚钱的5个层次,你在哪一层?
[wc2021] Fibonacci - number theory, Fibonacci sequence
云主机mysql在本地电脑连接不上
1015 theory of virtue and talent