本文介绍了MongoDB 的默认数据库路径是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到一个关于 dbpath (/data/db/) 不存在的错误,但 /etc/mongodb.conf 将它命名为 dbpath =/var/lib/mongodb.那么,MongoDB 的默认 dbpath 是什么?

I got an error about dbpath (/data/db/) does not exist, but /etc/mongodb.conf named it dbpath = /var/lib/mongodb.So, which is the default dbpath for MongoDB?

推荐答案

mongodb 默认的 dbpath 是 /data/db.

The default dbpath for mongodb is /data/db.

没有默认配置文件,因此您需要在启动 mongod 时指定它:

There is no default config file, so you will either need to specify this when starting mongod with:

 mongod --config /etc/mongodb.conf

.. 或使用 MongoDB 的打包安装(例如 RedhatDebian/Ubuntu),它将在服务定义中包含配置文件路径.

.. or use a packaged install of MongoDB (such as for Redhat or Debian/Ubuntu) which will include a config file path in the service definition.

注意:要检查正在运行的 mongod 的 dbpath 和命令行选项,请通过 mongo shell 连接并运行:

Note: to check the dbpath and command-line options for a running mongod, connect via the mongo shell and run:

db.serverCmdLineOpts()

特别是,如果设置了自定义 dbpath,它将是以下值:

In particular, if a custom dbpath is set it will be the value of:

db.serverCmdLineOpts().parsed.dbpath           // MongoDB 2.4 and older
db.serverCmdLineOpts().parsed.storage.dbPath   // MongoDB 2.6+

这篇关于MongoDB 的默认数据库路径是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 12:23