MongoDB的默认数据库路径是什么? [英] What is the default database path for MongoDB?

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

问题描述

我收到关于dbpath (/data/db/) does not exist的错误,但/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的打包安装(例如用于 Debian/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的默认数据库路径是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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