How to reduce the file size of a MongoDB database

1146765 pts.
Tags:
Big Data
MongoDB
My friend and I have a MongoDB database which was pretty large (over 3 GB). But we recently deleted a bunch of documents, files, etc., and we thought that would lead to the size of the database files to go down. But since MongoDB keeps allotted space, our files are still big. We read that mongod -- repair is used to reduce unused space, but we don't have enough space to run it. Is there a way to free up the space?
1

Answer Wiki

Thanks. We'll let you know when a new response is added.
Hi ITKE,
You will easily reduce the file size of a MongoDB database by this using of this at command line:
mongodump -d databasename
echo ‘db.dropDatabase()’ | mongo databasename
mongorestore dump/databasename
I hope it will helpful for you to resolve your problems.
Thanks & Regards
Clark Kent

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: