mongodb数据库在Mac上的位置 [英] Location of the mongodb database on mac

查看:54
本文介绍了mongodb数据库在Mac上的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Mac和mongodb都是新手.

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?

我知道,在Windows中有一个名为c:\ data \ db的文件夹,用于存储我的数据库文件.

I know, in windows there is a folder called c:\data\db, where my database files are stored.

在Mac中,数据库的存储方式和存储位置.

How and where in mac, the database is stored.

我记得做过类似的事情

sudo mkdir -p /data/db
sudo chown `id -u` /data/db

要在Mac上创建这样的文件夹,但是尽管我创建了数据库,但在此文件夹中没有找到任何数据库文件.

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?

任何帮助将不胜感激.

Any help would be really appreciated.

推荐答案

MongoDB的默认数据目录为/data/db.

The default data directory for MongoDB is /data/db.

可由 dbpath选项覆盖在命令行或配置文件中指定.

This can be overridden by a dbpath option specified on the command line or in a configuration file.

如果您通过

If you install MongoDB via a package manager such as Homebrew or MacPorts these installs typically create a default data directory other than /data/db and set the dbpath in a configuration file.

如果在启动时向mongod提供了dbpath,则可以检查mongo shell中的值:

If a dbpath was provided to mongod on startup you can check the value in the mongo shell:

db.serverCmdLineOpts()

您会看到类似的值:

"parsed" : {
    "dbpath" : "/usr/local/data"
},

这篇关于mongodb数据库在Mac上的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆