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.
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.
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