Mongo db change datadir

Posted BioMarkerInfo

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Mongo db change datadir相关的知识,希望对你有一定的参考价值。

To change the location used by MongoDB to store its data, you need to:

  1. Edit /etc/mongodb.conf and change the line dbpath=/var/lib/mongodb to the path that you desire, e.g. dbpath=/home/user/data/mongodb
  2. Update the permissions of your chosen path to allow the mongodb user to write to it, e.g. chown $USER -R /home/user/data/mongodb
  3. Restart the MongoDB service by running sudo service mongodb restart

Note that if you have any data in the old location that you want to keep, you‘ll need to stop the MongoDB service first, manually move the files and then start the service again.

To stop the MongoDB server use sudo service mongodb stop

以上是关于Mongo db change datadir的主要内容,如果未能解决你的问题,请参考以下文章

mongo源码学习db.cpp之mongoDbMain方法分析

Mongo Change Stream给我收藏的所有更改?

Mongo DB删除重复数据文档实践

Spring Mongo DB @DBREF

Mongo DB 简单搭建和部署

如何在 java 中检查集合 mongo db? [复制]