To change the location used by MongoDB to store its data, you need to:
- Edit
/etc/mongodb.confand change the linedbpath=/var/lib/mongodbto the path that you desire, e.g.dbpath=/home/user/data/mongodb - Update the permissions of your chosen path to allow the
mongodbuser 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
本文介绍如何修改MongoDB的数据存储位置,包括编辑配置文件、更新权限和重启服务的步骤。若要保留旧数据,需先停止服务并手动迁移文件。
2332

被折叠的 条评论
为什么被折叠?



