首页 > 代码库 > Mongo db change datadir
Mongo db change datadir
To change the location used by MongoDB to store its data, you need to:
- Edit
/etc/mongodb.conf
and change the linedbpath=/var/lib/mongodb
to the path that you desire, e.g.dbpath=/home/user/data/mongodb
- 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
- 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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。