Listing Databases
The most basic command for listing the databases in the MongoDB shell is ‘show dbs‘. This command prints the list of databases and their sizes. On the other hand, we need to understand that MongoDB has only databases that have data. Empty databases will never show in the output.
show dbs
Output:
Explanation: As we have seen in the image that we have List of all the databases which we had created.
How to List all Databases in the Mongo Shell?
MongoDB is a popular NoSQL database that allows for flexible and scalable data storage. When working with MongoDB, it’s essential to understand how to list all databases to manage them effectively. By using commands such as show dbs
and db.stats()
, users can gain insights into their database environment, including database sizes and collection counts.
In this article, We will explores the steps involved in listing all databases in MongoDB and interpreting the output and so on.