Step 1: Stop the service
sudo service mongod stop
Step 2: Remove packages
sudo apt-get purge mongodb-org*
Step 3: Remove data directories
sudo rm -r /var/log/mongodb
sudo rm -r /var/lib/mongodb
-r means recursive
Reference: https://docs.mongodb.org/v3.0/tutorial/install-mongodb-on-ubuntu/
when i type this command sudo service mongod stop the ff error is raised
Failed to stop mongod.service: Unit mongod.service not loaded.
How about just check the offical mongodb docs?
Oh; wait; it’s exactly the same as your answer…
should be in my case
sudo service mongodb stop
Don’t forget to
rm -rf /etc/
folder as well (If you don’t intend on keeping the data). Mongo pre-allocates file sizes, meaning even if you have an almost empty database, the files still occupy a substantial amount of storage.
Hmm
Do not rm -rf /etc/ that will delete the entire etc folder with everything else
-_-
Be careful with that command, you don’t want to delete all the “etc” directory
DONT TRY THIS. It will delete the entire etc folder. A$$hole.
Why does the admin accept such a comment?? Do you really understand this stuff? Or just copying from askubuntu?
Good point! Seems like this comment slipped through. Thanks for picking this up.
Thank you a lot!
I install the wrong version for my ubuntu, and when i tried to install the correct version it was impossible.
This command sudo rm -r /var/log/mongodb solve the problem. thanks
Luka’s response above of rm -rf /etc/ will completely screw your computer.
Don’t run this command. It will delete the entire directory that contains all your config files.