mongodb 数据库在 mac 上的位置
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13827915/
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
Location of the mongodb database on mac
提问by Spaniard89
I am kind of new to mac as well as mongodb.
我是 mac 和 mongodb 的新手。
I have a weird doubt, accessing the database created using mongodb on mac?
我有一个奇怪的疑问,在 mac 上访问使用 mongodb 创建的数据库?
I know, in windows there is a folder called c:\data\db, where my database files are stored.
我知道,在 Windows 中有一个名为 c:\data\db 的文件夹,其中存储了我的数据库文件。
How and where in mac, the database is stored.
数据库在 mac 中的存储方式和位置。
I remember doing something like
我记得做类似的事情
sudo mkdir -p /data/db
sudo chown `id -u` /data/db
to create such a folder on mac, but I didn't find any database file in this folder, though i created a database.
在mac上创建这样一个文件夹,但是我在这个文件夹中没有找到任何数据库文件,尽管我创建了一个数据库。
Where are the database files saved on mac?
mac上保存的数据库文件在哪里?
Any help would be really appreciated.
任何帮助将非常感激。
回答by Mark Edington
If mongodb is installed via Homebrew the default location is:
如果 mongodb 是通过 Homebrew 安装的,默认位置是:
/usr/local/var/mongodb
/usr/local/var/mongodb
See the answer from @simonbogarde for the location of other interesting files that are different when using Homebrew.
有关使用 Homebrew 时不同的其他有趣文件的位置,请参阅@simonbogarde 的答案。
回答by simonbogarde
Thanks @Mark, I keep forgetting this again and again. After installing MongoDB with Homebrew:
谢谢@Mark,我一次又一次地忘记了这一点。使用 Homebrew 安装 MongoDB 后:
- The databases are stored in the /usr/local/var/mongodb/directory
- The mongod.conf file is here: /usr/local/etc/mongod.conf
- The mongo logs can be found at /usr/local/var/log/mongodb/
- The mongo binaries are here: /usr/local/Cellar/mongodb/[version]/bin
- 数据库存储在/usr/local/var/mongodb/目录中
- mongod.conf 文件在这里:/usr/local/etc/mongod.conf
- 可以在/usr/local/var/log/mongodb/找到 mongo 日志
- mongo 二进制文件在这里:/usr/local/Cellar/mongodb/[version]/bin
回答by Stennie
The default data directory for MongoDB is /data/db
.
MongoDB 的默认数据目录是/data/db
.
This can be overridden by a dbpath
optionspecified on the command line or in a configuration file.
这可以被命令行或配置文件中指定的dbpath
选项覆盖。
If you install MongoDB via a package managersuch as Homebrew or MacPorts these installs typically create a default data directory other than /data/db and set the dbpath in a configuration file.
如果您通过Homebrew 或 MacPorts 等包管理器安装 MongoDB,这些安装通常会创建一个默认数据目录而不是 /data/db 并在配置文件中设置 dbpath。
If a dbpath was provided to mongod
on startup you can check the value in the mongo
shell:
如果mongod
在启动时提供了 dbpath,您可以检查mongo
shell 中的值:
db.serverCmdLineOpts()
You would see a value like:
您会看到如下值:
"parsed" : {
"dbpath" : "/usr/local/data"
},
回答by Runnerdave
I had the same problem, with version 3.4.2
我有同样的问题,版本 3.4.2
to run it (if you installed it with homebrew) run the process like this:
运行它(如果你用自制软件安装它)运行这样的过程:
$ mongod --dbpath /usr/local/var/mongodb
回答by csonuryilmaz
I have just installed mongodb 3.4with homebrew.(brew install mongodb) It looks for /data/dbby default.
我刚刚用homebrew安装了mongodb 3.4。(brew install mongodb)它默认查找/data/db。
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/
回答by jyjin
Env: macOS Mojave 10.14.4
环境:macOS Mojave 10.14.4
Install: homebrew
安装:自制
Location:/usr/local/Cellar/mongodb/4.0.3_1
地点:/usr/local/Cellar/mongodb/4.0.3_1
Note:If update version by
brew upgrade mongo
,the folder 4.0.4_1
will be removed and replace with the new version folder
注意:如果更新版本
brew upgrade mongo
,该文件夹4.0.4_1
将被删除并替换为新版本文件夹