Oliver Bayes-Shelton
Oliver Bayes-Shelton

Reputation: 6292

Where does MongoDB store its documents?

I have inserted and fetched data using MongoDB, in PHP. Is there an actual copy of this data in a document somewhere?

Upvotes: 29

Views: 42200

Answers (2)

Daniel Cassidy
Daniel Cassidy

Reputation: 25627

By default Mongo stores its data in the directory /data/db.

You can specify a different directory using the --dbpath option.

If you’re running Mongo on Windows then the directory will be C:\data\db, where C is the drive letter of the working directory in which Mongo was started. This is quite confusing, so on Windows I’d recommend that you always specify a data directory using --dbpath.

Upvotes: 32

Emil Vikström
Emil Vikström

Reputation: 91963

MongoDB stores it's data in the data directory specified by --dbpath. It uses a database format so it's not actual documents, but there are multiple documents in each file and you cannot easily extract the data from this format yourself.

To read and/or update a document you need to use a MongoDB client, in the same way that you send SQL queries to MySQL through a MySQL client. You probably want to do it programmatically by using one of the client libraries for your programming language, but there is also a command-line client if you need to do manual updates.

Upvotes: 21

Related Questions