MongoDB 在哪里存储它的文档?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6437291/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 12:07:48  来源:igfitidea点击:

Where does MongoDB store its documents?

mongodb

提问by Oliver Bayes-Shelton

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

我已经在 PHP 中使用 MongoDB 插入和获取数据。在某处的文档中是否有这些数据的实际副本?

采纳答案by Emil Vikstr?m

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

MongoDB 将其数据存储在--dbpath指定的数据目录中。它使用数据库格式,所以它不是实际的文档,但每个文件中有多个文档,您自己无法轻松地从这种格式中提取数据。

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 librariesfor your programming language, but there is also a command-line clientif you need to do manual updates.

要读取和/或更新文档,您需要使用 MongoDB 客户端,就像通过 MySQL 客户端向 MySQL 发送 SQL 查询一样。您可能希望通过使用您的编程语言的客户端库之一以编程方式执行此操作,但如果您需要进行手动更新,也可以使用命令行客户端

回答by Daniel Cassidy

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

默认情况下,Mongo 将其数据存储在目录中/data/db

You can specify a different directory using the --dbpathoption.

您可以使用该--dbpath选项指定不同的目录。

If you're running Mongo on Windows then the directory will be C:\data\db, where Cis 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.

如果您在 Windows 上运行 Mongo,那么目录将为C:\data\db,其中C是启动 Mongo 的工作目录的驱动器号。这很令人困惑,因此在 Windows 上我建议您始终使用--dbpath.