Why SHOW DBS does not show my databases in MongoDB?

The SHOW DBS command in MongoDB will not display a database until that database contains at least one collection with documents. MongoDB only allocates disk space for databases that actually contain data, which is why empty databases remain invisible in the database list.

Syntax

show dbs;
// OR
show databases;

Example: Creating a Database

Let's create a database named "web" and see why it doesn't appear in the database list ?

use web;
switched to db web

Now let's check all databases ?

show dbs;
admin 0.001GB
config 0.000GB
local 0.000GB
my 0.001GB
sample 0.001GB
test 0.010GB

Notice that the "web" database is not visible because we haven't created any collections or documents in it yet.

Making the Database Visible

To make the database appear, we need to create a collection with at least one document ?

db.users.insertOne({"ClientName": "John"});
{
    "acknowledged": true,
    "insertedId": ObjectId("5cb806c2623186894665ae35")
}

Let's verify the document was created ?

db.users.find();
{ "_id": ObjectId("5cb806c2623186894665ae35"), "ClientName": "John" }

Now let's check the database list again ?

show dbs;
admin 0.001GB
config 0.000GB
local 0.000GB
my 0.001GB
sample 0.001GB
test 0.010GB
web 0.000GB

The "web" database is now visible because it contains actual data.

Key Points

  • MongoDB databases are lazy-created ? they don't physically exist until they contain data
  • Use use databaseName to switch to a database, but it won't appear in listings until it has collections
  • Empty databases consume no disk space and remain invisible to show dbs

Conclusion

MongoDB's show dbs command only displays databases that contain collections with documents. To make a new database visible, create at least one collection and insert a document into it.

Updated on: 2026-03-15T00:46:07+05:30

4K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements