Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

uninstalling mongo

I am having trouble uninstalling mongo from a 64 bit EC2. In /usr/bin I have mongo and mongod amongst others. When I type mongo from anywhere it opens the shell at version 1.8. I now downloaded 2.0.2 and in that folder when I run mongo it opens up version 2.0.2

My question is how do I purge mongo fully so I can install 2.0.2 without coming across the old 1.8 version?

EDIT: I believe I used yum (it was a while ago), and I think the ec2 is fedora.

like image 264
fullstacklife Avatar asked Jan 07 '12 01:01

fullstacklife


People also ask

How do I start MongoDB from terminal?

Run the Mongo daemon, in one terminal window run ~/mongodb/bin/mongod . This will start the Mongo server. Run the Mongo shell, with the Mongo daemon running in one terminal, type ~/mongodb/bin/mongo in another terminal window. This will run the Mongo shell which is an application to access data in MongoDB.

How do I remove all data from a collection in MongoDB?

To delete all documents in a collection, pass an empty document ( {} ). Optional. To limit the deletion to just one document, set to true . Omit to use the default value of false and delete all documents matching the deletion criteria.

How do I know if MongoDB is installed?

Open the command prompt and type "cd c:\program files\mongodb\server\your version\bin". After you enter the bin folder type "mongo start". If you get either a successful connection or failed one it means it's installed at least.


8 Answers

1.Stop Mongo DB using -

sudo service mongod stop

2.Remove Packages using -

sudo yum erase $(rpm -qa | grep mongodb-org)

3.Remove Data Directories using -

sudo rm -r /var/log/mongodb
sudo rm -r /var/lib/mongo
like image 173
Animesh Prosad Avatar answered Sep 25 '22 07:09

Animesh Prosad


yum erase mongo-10gen mongo-10gen-server

like image 35
Dennis Do Avatar answered Sep 28 '22 07:09

Dennis Do


I needed to run a yum list installed | grep mongo then yum remove those packaged

like image 33
James Dunmore Avatar answered Sep 28 '22 07:09

James Dunmore


This should work

rpm -qa | less | grep mongo

using that command will give you the mongo packages you have installed, after that you can do

rpm -qa | less | grep mongo | xargs yum remove // <-- this will remove all packages automatically

but can also remove all of them Manually

like image 31
Diego Velez Avatar answered Sep 27 '22 07:09

Diego Velez


this gets the job done easily

sudo yum erase mongodb-org*
like image 23
tsukimi Avatar answered Sep 25 '22 07:09

tsukimi


First stop the mongo service

sudo service mongod stop

Then remove the packages

sudo yum erase $(rpm -qa | grep mongodb-org)

Then remove the log(data) directories

sudo rm -r /var/log/mongodb

sudo rm -r /var/lib/mongo

like image 44
nixxo_raa Avatar answered Sep 29 '22 07:09

nixxo_raa


For Ubuntu users:

First, stop the service of MongoDB and then try uninstalling mongod.

Then, type these commands to uninstall mongodb:

sudo apt-get purge mongodb mongodb-clients mongodb-server mongodb-dev

sudo apt-get purge mongodb-10gen

sudo apt-get autoremove
like image 24
Diwakar upadhyay Avatar answered Sep 26 '22 07:09

Diwakar upadhyay


I used dnf command to list and uninstall mongodb from my EC2 servers (RedHat Enterprise Linux 8). Hope this helps for the RHEL8 users.

DNF_ is the next upcoming major version of YUM_, a package manager for RPM-based Linux distributions. It roughly maintains CLI compatibility with YUM and defines a strict API for extensions and plugins.

For further reading about DNF usage...

https://dnf.readthedocs.io/en/latest/command_ref.html

To list down the mongodb installations (Use sudo if required)

sudo dnf list installed|grep mongodb

enter image description here

To uninstall/remove mongodb

sudo dnf remove mongodb-org

enter image description here

Then run the list command again to see if the installation is successful. It shouldn't show any mongodb-org packages if the uninstallation was successful.

sudo dnf list installed|grep mongodb
like image 34
SajithP Avatar answered Sep 26 '22 07:09

SajithP