- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to list all databases in the Mongo shell?
To list all databases in the Mongo shell, you need to use show command. The syntax is as follows −
show dbs;
Let us implement the above syntax for MongoDB. The query is as follows −
> show dbs;
The following is the output −
admin 0.000GB config 0.000GB local 0.000GB sample 0.000GB sampleDemo 0.000GB test 0.003GB
If you create a new database in MongoDB then it won’t be present in list of databases.
Let us check the same. Create a new database −
> use studentTracker; switched to db studentTracker
Now list all the databases from Mongo shell. The query is as follows −
> show dbs;
The following is the output −
admin 0.000GB config 0.000GB local 0.000GB sample 0.000GB sampleDemo 0.000GB test 0.003GB
Look at the above sample output, the database ‘studentTracker’ is not present in database list. This is because the database is empty and it isn’t having any collection −
Note: In order to display the newly created database in the list, you need to create a collection in the new database.
- Related Articles
- How to list all collections in the Mongo shell?
- How to list all users in the Mongo shell?
- How to operate on all databases from the MongoDB shell?
- Inserting Date() in MongoDB through Mongo shell?
- How to get the list of all databases using JDBC?
- How to get the list of all the MongoDB databases using java?
- How to get all the collections from all the MongoDB databases?
- List of non-empty tables in all your MySQL databases?
- How to iterate over all MongoDB databases?
- How to list databases vertically in MySQL command line?
- Does Mongo shell treats numbers as float by default.? How can we work it around explicitly?
- How can I restore multiple databases or all databases dumped by mysqldump?
- MySQL permissions to view all databases?
- Return list of databases in MySQL?
- How to GRANT SELECT ON all tables in all databases on a server with MySQL?

Advertisements