Where is my data stored?

I have specified a directory for my databases, but i cannot see the files. I have created 2 databases, “test” and “eieio”. I can see them at the command prompt using “db”, and i can do CRUD operations on them. But, when i look at my folder in windows explorer, they are not there, neither can i search for them in Windows taskbar search. Can someone tell me where to look and what to look for?

Thanks!!

1 Like

They are in the directory specified by your dbpath. However the name of the files do not reflect the name of the collections.

just in case it was not set to what you thought you did you can look in the local.startup_log collection

use local
db.startup_log.find().sort({startTime:-1}).limit(1).pretty()

Or slightly modified for brevity:

db.startup_log.find({},{cmdLine:1}).sort({startTime:-1}).limit(1).pretty()
{
	"_id" : "5ca6d0cdf984-1582162763917",
	"cmdLine" : {
		"net" : {
			"bindIpAll" : true
		},
		"replication" : {
			"replSet" : "s0"
		},
		"security" : {
			"authorization" : "enabled",
			"keyFile" : "/keyfile"
		}
	}
}

mongod has an option to create separate directories for each database. For your existing deployment, you can create separate directories for each database using the option –directoryperdb (and following instructions in the documentation).

1 Like

image

This is my db folder. I searched documentation for .wt, but tons of info comes up. Is there some page that gives brief overview of these various files and folders that gives some explanation of structure and use?

Thanks!

1 Like

That is your database files.

What exactly are you trying to achieve?

would just like to understand what i am seeing. i have done a lot of MS Access work over the years and i can open tables, see the text in queries, etc. I was just wondering if these various files can be opened with a text editor, which file contains my data, and so forth.

Thinking about backup too. Would i just backup everything in the folder and call it a day? Just trying to understand what i am seeing.

Thanks!

1 Like

If you are wanting to ad-hoc navigate and query your database you’ll want to use a GUI client like MongoDB Compass or the mongo command line interface.

Your instinct on backup is essentially accurate, there are a few other ways and considerations that make good reading https://docs.mongodb.com/manual/core/backups/

1 Like

That makes sense. I tried Compass, it works great. I guess that i was thinking that MongoDB stored data in a text file full of json. Really, i am just trying to get familiar with the workings of Mongo.

Thanks!

1 Like

MongoDB stores data and indexes on disk in a compressed binary format. Individual documents are represented in BSON, a binary JSON-like serialisation format that supports additional data types such as dates, 32-bit integers, 64-bit integers, 128-bit decimals, ObjectIDs, and binary data.

Data is written to disk using block compression for documents and prefix compression for indexes. Compression defaults are configurable at a global level and can also be set on a per-collection and per-index basis during collection and index creation.

For further reading that might provide helpful background info, see:

Regards,
Stennie

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.