Move Mongo Database to a different location

I want to run MongoDB on an Amazon EC2 off the ephemeral drive – so I need to change the location of the database.

There are two ways

Firstly, edit the /etc/mongodb.conf file

dbpath = /mnt/mongodb

Or Secondly, symlink the data folder.

service mongodb stop
cd /var/lib
mv mongodb /mnt
ln -s /mnt/mongodb mongodb
chown mongodb:mongodb mongdo
service mongodb start

Leave a Reply