Uninstall mongodb correctly and install mongodb again

Please teach me how to remove my mongodb in my virtualbox (ubuntu).

I tried this command and nothing was removed:

sudo apt-get purge mongodb mongodb-clients mongodb-server mongodb-dev
sudo apt-get purge mongodb-10gen
sudo apt-get autoremove

      

It still exists. I'm typing mongod --version

showsdb version v2.6.1

Update:

I want to remove it and then install it again:

I have tried the following 4 commands -

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list
sudo apt-get update
sudo apt-get install mongodb-org

      

then sudo service mongod start

and enter mongo

, there is an error:

MongoDB shell version: 2.6.4
connecting to: test
2014-09-02T21:27:10.390+0800 warning: Failed to connect to 127.0.0.1:27017, reason: errno:111     Connection refused
2014-09-02T21:27:10.392+0800 Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed at src/mongo/shell/mongo.js:146
exception: connect failed

      

Did I miss something? Please help me. Thank!

+3


source to share


1 answer


Usually with apt command you can run autoremove with all mongoDB packages:

sudo apt-get autoremove mongodb-*

      

Ok in mongodb documentation, packages have changed. To have an updated package, follow the instructions:

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10

      

Create a list file /etc/apt/sources.list.d/mongodb.list

using the following command:

echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list

      

Run the following command to reload the local package database:



sudo apt-get update

      

And install the packages you want:

sudo apt-get install mongodb-org

      

After that, you have server, shell, mongos, ... To start mongodb server you can start mongodb service like this:

sudo service mongod start

      

To connect to your local server, enter this command:

mongo

      

+6


source







All Articles