Uninstall MongoDB in Ubuntu via command line in 3 easy steps

By | December 27, 2015

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/

4 thoughts on “Uninstall MongoDB in Ubuntu via command line in 3 easy steps

  1. Tadese

    when i type this command sudo service mongod stop the ff error is raised
    Failed to stop mongod.service: Unit mongod.service not loaded.

    Reply
  2. Luka

    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.

    Reply
  3. Armando

    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

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *