To change the location used by MongoDB to store its data, you need to:
/etc/mongodb.conf and change the line dbpath=/var/lib/mongodb to the path that you desire, e.g. dbpath=/home/user/data/mongodbmongodb user to write to it, e.g. chown $USER -R /home/user/data/mongodbsudo service mongodb restartNote 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
原文:http://www.cnblogs.com/xiaojikuaipao/p/6874892.html