How can I uninstall MongoDB and reinstall the latest version?












48















I need to uninstall mongodb completely from my system (Ubuntu 11.10) and install version 2.0.5.



Currently, when I run:



mongo db


I get the following error:




MongoDB shell version: 2.0.1

connecting to: db

Wed Jun 6 13:05:03 Error: couldn't connect to server 127.0.0.1 shell/mongo.js:84
exception: connect failed











share|improve this question

























  • Try with: downloads-distro.mongodb.org/repo/ubuntu-upstart/dists/dist/…

    – jasmines
    Jun 6 '12 at 7:40
















48















I need to uninstall mongodb completely from my system (Ubuntu 11.10) and install version 2.0.5.



Currently, when I run:



mongo db


I get the following error:




MongoDB shell version: 2.0.1

connecting to: db

Wed Jun 6 13:05:03 Error: couldn't connect to server 127.0.0.1 shell/mongo.js:84
exception: connect failed











share|improve this question

























  • Try with: downloads-distro.mongodb.org/repo/ubuntu-upstart/dists/dist/…

    – jasmines
    Jun 6 '12 at 7:40














48












48








48


18






I need to uninstall mongodb completely from my system (Ubuntu 11.10) and install version 2.0.5.



Currently, when I run:



mongo db


I get the following error:




MongoDB shell version: 2.0.1

connecting to: db

Wed Jun 6 13:05:03 Error: couldn't connect to server 127.0.0.1 shell/mongo.js:84
exception: connect failed











share|improve this question
















I need to uninstall mongodb completely from my system (Ubuntu 11.10) and install version 2.0.5.



Currently, when I run:



mongo db


I get the following error:




MongoDB shell version: 2.0.1

connecting to: db

Wed Jun 6 13:05:03 Error: couldn't connect to server 127.0.0.1 shell/mongo.js:84
exception: connect failed








11.10 mongodb






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jun 6 '12 at 9:48









David Edwards

4,13232542




4,13232542










asked Jun 6 '12 at 7:35









jyothijyothi

241133




241133













  • Try with: downloads-distro.mongodb.org/repo/ubuntu-upstart/dists/dist/…

    – jasmines
    Jun 6 '12 at 7:40



















  • Try with: downloads-distro.mongodb.org/repo/ubuntu-upstart/dists/dist/…

    – jasmines
    Jun 6 '12 at 7:40

















Try with: downloads-distro.mongodb.org/repo/ubuntu-upstart/dists/dist/…

– jasmines
Jun 6 '12 at 7:40





Try with: downloads-distro.mongodb.org/repo/ubuntu-upstart/dists/dist/…

– jasmines
Jun 6 '12 at 7:40










3 Answers
3






active

oldest

votes


















81














There are two sets of packages for MongoDB; the standard Ubuntu packages, and a set published by 10gen themselves. The standard packages are out of date, especially for older releases of Ubuntu, so it is probably a good idea to set yourself up to install from the 10gen repositories.



The error message you quote suggests that you might have already tried this, since version 2.0.1 is not a standard Ubuntu package. I suggest that first of all, you completely uninstall Mongo and clean up your system. If you have existing data that you want to keep, you could take a backup of it. By default, it is stored in /var/lib/mongodb. So if you want to take a backup, take a copy of the files from there and keep them in a safe place.



Uninstalling existing MongoDB packages



Since I'm not 100% what you've got installed, I suggest the following to make sure everything is uninstalled:



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


Some of those commands may fail, depending on what packages you actually have installed, but that's okay.



This should also remove your config from /etc/mongodb.conf. If you want to completely clean up, you might also want to remove the data directory /var/lib/mongodb, so long as you backed it up or don't want it any more.



If you've installed by building from source or using the 10gen binary distributions, then you'll need to manually uninstall and clean up from wherever you put the binary files, config and data files.



Installing the 10gen MongoDB packages



Follow the 10gen instructions for adding their repository:



sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10


Edit /etc/apt/sources.list, delete any lines you have already added for Mongo, and add the following single line (since 11.10 uses upstart) at the end:



deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen


Note that if you add this repository using the Software Center, it will automatically add a deb-src entry, which will break apt-get. So you will need to edit your sources list by hand to add only the above line.



Then to install, run:



sudo apt-get update 
sudo apt-get install mongodb-10gen


Checking your install



Installing the packages should automatically start up the MongoDB server. So you should be able to run the client from the command line:



mongo


which should successfully connect to the test database. You can quit by typing exit.



If that fails, please update your question with further details, including the output of trying to connect and attaching your /var/log/mongodb/mongodb.log file.






share|improve this answer


























  • maisapride1@maisapride1:/$ sudo apt-get purge mongodb mongodb-clients mongodb-server mongodb-dev Reading package lists... Done Building dependency tree Reading state information... Done Package mongodb is not installed, so not removed Package mongodb-clients is not installed, so not removed Package mongodb-dev is not installed, so not removed Package mongodb-server is not installed, so not removed 0 upgraded, 0 newly installed, 0 to remove and 406 not upgraded. -----when trying to remove, when i again give mongo it showing the vesion:MongoDB shell version: 2.0.1

    – jyothi
    Jun 6 '12 at 10:02













  • That is fine; as I said, some of those commands may fail, depending on which packages you have installed. Those particular errors show that you did not have the standard Ubuntu MongoDB packages installed.

    – David Edwards
    Jun 6 '12 at 10:07











  • Have you run the second command to remove the 10gen packages? If that removes nothing too, and you can still run the mongo client, then you must have done a manual install and you will have to delete by hand.

    – David Edwards
    Jun 6 '12 at 10:30











  • can i know how to install or to update mongo db to 2.0.5 from 2.0.1

    – jyothi
    Jun 6 '12 at 10:59













  • Installing the 10gen packages as described in my answer will give you 2.0.6. Previous versions are available for download and manual install from the MongoDB website, but I strongly suggest you stick to the packaged versions.

    – David Edwards
    Jun 6 '12 at 11:15





















25














To completely remove MongoDB from a system, you must remove the MongoDB applications themselves, the configuration files, and any directories containing data and logs. The following section guides you through the necessary steps.





  1. Stop MongoDB



    Stop the mongod process by issuing the following command:



    sudo service mongod stop



  2. Remove Packages



    Remove any MongoDB packages that you had previously installed.



    sudo apt-get purge mongodb-org*



  3. Remove Data Directories.



    Remove MongoDB databases and log files.



    sudo rm -r /var/log/mongodb /var/lib/mongodb







share|improve this answer

































    4














    Follow the steps:





    1. Remove lock file



      sudo rm /var/lib/mongodb/mongod.lock



    2. Repair mongodb



      mongod --repair



    3. Start mongodb



      sudo service mongodb start



    4. Start mongo console



      mongo







    share|improve this answer


























    • @stumblebee: Please watch out for edit suggestions like this one! The service name is indeed mongodb as in the original version and you can verify that via the package file list.

      – David Foerster
      May 2 '18 at 8:01












    protected by Community Feb 7 at 6:01



    Thank you for your interest in this question.
    Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



    Would you like to answer one of these unanswered questions instead?














    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    81














    There are two sets of packages for MongoDB; the standard Ubuntu packages, and a set published by 10gen themselves. The standard packages are out of date, especially for older releases of Ubuntu, so it is probably a good idea to set yourself up to install from the 10gen repositories.



    The error message you quote suggests that you might have already tried this, since version 2.0.1 is not a standard Ubuntu package. I suggest that first of all, you completely uninstall Mongo and clean up your system. If you have existing data that you want to keep, you could take a backup of it. By default, it is stored in /var/lib/mongodb. So if you want to take a backup, take a copy of the files from there and keep them in a safe place.



    Uninstalling existing MongoDB packages



    Since I'm not 100% what you've got installed, I suggest the following to make sure everything is uninstalled:



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


    Some of those commands may fail, depending on what packages you actually have installed, but that's okay.



    This should also remove your config from /etc/mongodb.conf. If you want to completely clean up, you might also want to remove the data directory /var/lib/mongodb, so long as you backed it up or don't want it any more.



    If you've installed by building from source or using the 10gen binary distributions, then you'll need to manually uninstall and clean up from wherever you put the binary files, config and data files.



    Installing the 10gen MongoDB packages



    Follow the 10gen instructions for adding their repository:



    sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10


    Edit /etc/apt/sources.list, delete any lines you have already added for Mongo, and add the following single line (since 11.10 uses upstart) at the end:



    deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen


    Note that if you add this repository using the Software Center, it will automatically add a deb-src entry, which will break apt-get. So you will need to edit your sources list by hand to add only the above line.



    Then to install, run:



    sudo apt-get update 
    sudo apt-get install mongodb-10gen


    Checking your install



    Installing the packages should automatically start up the MongoDB server. So you should be able to run the client from the command line:



    mongo


    which should successfully connect to the test database. You can quit by typing exit.



    If that fails, please update your question with further details, including the output of trying to connect and attaching your /var/log/mongodb/mongodb.log file.






    share|improve this answer


























    • maisapride1@maisapride1:/$ sudo apt-get purge mongodb mongodb-clients mongodb-server mongodb-dev Reading package lists... Done Building dependency tree Reading state information... Done Package mongodb is not installed, so not removed Package mongodb-clients is not installed, so not removed Package mongodb-dev is not installed, so not removed Package mongodb-server is not installed, so not removed 0 upgraded, 0 newly installed, 0 to remove and 406 not upgraded. -----when trying to remove, when i again give mongo it showing the vesion:MongoDB shell version: 2.0.1

      – jyothi
      Jun 6 '12 at 10:02













    • That is fine; as I said, some of those commands may fail, depending on which packages you have installed. Those particular errors show that you did not have the standard Ubuntu MongoDB packages installed.

      – David Edwards
      Jun 6 '12 at 10:07











    • Have you run the second command to remove the 10gen packages? If that removes nothing too, and you can still run the mongo client, then you must have done a manual install and you will have to delete by hand.

      – David Edwards
      Jun 6 '12 at 10:30











    • can i know how to install or to update mongo db to 2.0.5 from 2.0.1

      – jyothi
      Jun 6 '12 at 10:59













    • Installing the 10gen packages as described in my answer will give you 2.0.6. Previous versions are available for download and manual install from the MongoDB website, but I strongly suggest you stick to the packaged versions.

      – David Edwards
      Jun 6 '12 at 11:15


















    81














    There are two sets of packages for MongoDB; the standard Ubuntu packages, and a set published by 10gen themselves. The standard packages are out of date, especially for older releases of Ubuntu, so it is probably a good idea to set yourself up to install from the 10gen repositories.



    The error message you quote suggests that you might have already tried this, since version 2.0.1 is not a standard Ubuntu package. I suggest that first of all, you completely uninstall Mongo and clean up your system. If you have existing data that you want to keep, you could take a backup of it. By default, it is stored in /var/lib/mongodb. So if you want to take a backup, take a copy of the files from there and keep them in a safe place.



    Uninstalling existing MongoDB packages



    Since I'm not 100% what you've got installed, I suggest the following to make sure everything is uninstalled:



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


    Some of those commands may fail, depending on what packages you actually have installed, but that's okay.



    This should also remove your config from /etc/mongodb.conf. If you want to completely clean up, you might also want to remove the data directory /var/lib/mongodb, so long as you backed it up or don't want it any more.



    If you've installed by building from source or using the 10gen binary distributions, then you'll need to manually uninstall and clean up from wherever you put the binary files, config and data files.



    Installing the 10gen MongoDB packages



    Follow the 10gen instructions for adding their repository:



    sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10


    Edit /etc/apt/sources.list, delete any lines you have already added for Mongo, and add the following single line (since 11.10 uses upstart) at the end:



    deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen


    Note that if you add this repository using the Software Center, it will automatically add a deb-src entry, which will break apt-get. So you will need to edit your sources list by hand to add only the above line.



    Then to install, run:



    sudo apt-get update 
    sudo apt-get install mongodb-10gen


    Checking your install



    Installing the packages should automatically start up the MongoDB server. So you should be able to run the client from the command line:



    mongo


    which should successfully connect to the test database. You can quit by typing exit.



    If that fails, please update your question with further details, including the output of trying to connect and attaching your /var/log/mongodb/mongodb.log file.






    share|improve this answer


























    • maisapride1@maisapride1:/$ sudo apt-get purge mongodb mongodb-clients mongodb-server mongodb-dev Reading package lists... Done Building dependency tree Reading state information... Done Package mongodb is not installed, so not removed Package mongodb-clients is not installed, so not removed Package mongodb-dev is not installed, so not removed Package mongodb-server is not installed, so not removed 0 upgraded, 0 newly installed, 0 to remove and 406 not upgraded. -----when trying to remove, when i again give mongo it showing the vesion:MongoDB shell version: 2.0.1

      – jyothi
      Jun 6 '12 at 10:02













    • That is fine; as I said, some of those commands may fail, depending on which packages you have installed. Those particular errors show that you did not have the standard Ubuntu MongoDB packages installed.

      – David Edwards
      Jun 6 '12 at 10:07











    • Have you run the second command to remove the 10gen packages? If that removes nothing too, and you can still run the mongo client, then you must have done a manual install and you will have to delete by hand.

      – David Edwards
      Jun 6 '12 at 10:30











    • can i know how to install or to update mongo db to 2.0.5 from 2.0.1

      – jyothi
      Jun 6 '12 at 10:59













    • Installing the 10gen packages as described in my answer will give you 2.0.6. Previous versions are available for download and manual install from the MongoDB website, but I strongly suggest you stick to the packaged versions.

      – David Edwards
      Jun 6 '12 at 11:15
















    81












    81








    81







    There are two sets of packages for MongoDB; the standard Ubuntu packages, and a set published by 10gen themselves. The standard packages are out of date, especially for older releases of Ubuntu, so it is probably a good idea to set yourself up to install from the 10gen repositories.



    The error message you quote suggests that you might have already tried this, since version 2.0.1 is not a standard Ubuntu package. I suggest that first of all, you completely uninstall Mongo and clean up your system. If you have existing data that you want to keep, you could take a backup of it. By default, it is stored in /var/lib/mongodb. So if you want to take a backup, take a copy of the files from there and keep them in a safe place.



    Uninstalling existing MongoDB packages



    Since I'm not 100% what you've got installed, I suggest the following to make sure everything is uninstalled:



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


    Some of those commands may fail, depending on what packages you actually have installed, but that's okay.



    This should also remove your config from /etc/mongodb.conf. If you want to completely clean up, you might also want to remove the data directory /var/lib/mongodb, so long as you backed it up or don't want it any more.



    If you've installed by building from source or using the 10gen binary distributions, then you'll need to manually uninstall and clean up from wherever you put the binary files, config and data files.



    Installing the 10gen MongoDB packages



    Follow the 10gen instructions for adding their repository:



    sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10


    Edit /etc/apt/sources.list, delete any lines you have already added for Mongo, and add the following single line (since 11.10 uses upstart) at the end:



    deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen


    Note that if you add this repository using the Software Center, it will automatically add a deb-src entry, which will break apt-get. So you will need to edit your sources list by hand to add only the above line.



    Then to install, run:



    sudo apt-get update 
    sudo apt-get install mongodb-10gen


    Checking your install



    Installing the packages should automatically start up the MongoDB server. So you should be able to run the client from the command line:



    mongo


    which should successfully connect to the test database. You can quit by typing exit.



    If that fails, please update your question with further details, including the output of trying to connect and attaching your /var/log/mongodb/mongodb.log file.






    share|improve this answer















    There are two sets of packages for MongoDB; the standard Ubuntu packages, and a set published by 10gen themselves. The standard packages are out of date, especially for older releases of Ubuntu, so it is probably a good idea to set yourself up to install from the 10gen repositories.



    The error message you quote suggests that you might have already tried this, since version 2.0.1 is not a standard Ubuntu package. I suggest that first of all, you completely uninstall Mongo and clean up your system. If you have existing data that you want to keep, you could take a backup of it. By default, it is stored in /var/lib/mongodb. So if you want to take a backup, take a copy of the files from there and keep them in a safe place.



    Uninstalling existing MongoDB packages



    Since I'm not 100% what you've got installed, I suggest the following to make sure everything is uninstalled:



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


    Some of those commands may fail, depending on what packages you actually have installed, but that's okay.



    This should also remove your config from /etc/mongodb.conf. If you want to completely clean up, you might also want to remove the data directory /var/lib/mongodb, so long as you backed it up or don't want it any more.



    If you've installed by building from source or using the 10gen binary distributions, then you'll need to manually uninstall and clean up from wherever you put the binary files, config and data files.



    Installing the 10gen MongoDB packages



    Follow the 10gen instructions for adding their repository:



    sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10


    Edit /etc/apt/sources.list, delete any lines you have already added for Mongo, and add the following single line (since 11.10 uses upstart) at the end:



    deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen


    Note that if you add this repository using the Software Center, it will automatically add a deb-src entry, which will break apt-get. So you will need to edit your sources list by hand to add only the above line.



    Then to install, run:



    sudo apt-get update 
    sudo apt-get install mongodb-10gen


    Checking your install



    Installing the packages should automatically start up the MongoDB server. So you should be able to run the client from the command line:



    mongo


    which should successfully connect to the test database. You can quit by typing exit.



    If that fails, please update your question with further details, including the output of trying to connect and attaching your /var/log/mongodb/mongodb.log file.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Jun 17 '16 at 6:30









    Chaitanya Bapat

    1136




    1136










    answered Jun 6 '12 at 9:40









    David EdwardsDavid Edwards

    4,13232542




    4,13232542













    • maisapride1@maisapride1:/$ sudo apt-get purge mongodb mongodb-clients mongodb-server mongodb-dev Reading package lists... Done Building dependency tree Reading state information... Done Package mongodb is not installed, so not removed Package mongodb-clients is not installed, so not removed Package mongodb-dev is not installed, so not removed Package mongodb-server is not installed, so not removed 0 upgraded, 0 newly installed, 0 to remove and 406 not upgraded. -----when trying to remove, when i again give mongo it showing the vesion:MongoDB shell version: 2.0.1

      – jyothi
      Jun 6 '12 at 10:02













    • That is fine; as I said, some of those commands may fail, depending on which packages you have installed. Those particular errors show that you did not have the standard Ubuntu MongoDB packages installed.

      – David Edwards
      Jun 6 '12 at 10:07











    • Have you run the second command to remove the 10gen packages? If that removes nothing too, and you can still run the mongo client, then you must have done a manual install and you will have to delete by hand.

      – David Edwards
      Jun 6 '12 at 10:30











    • can i know how to install or to update mongo db to 2.0.5 from 2.0.1

      – jyothi
      Jun 6 '12 at 10:59













    • Installing the 10gen packages as described in my answer will give you 2.0.6. Previous versions are available for download and manual install from the MongoDB website, but I strongly suggest you stick to the packaged versions.

      – David Edwards
      Jun 6 '12 at 11:15





















    • maisapride1@maisapride1:/$ sudo apt-get purge mongodb mongodb-clients mongodb-server mongodb-dev Reading package lists... Done Building dependency tree Reading state information... Done Package mongodb is not installed, so not removed Package mongodb-clients is not installed, so not removed Package mongodb-dev is not installed, so not removed Package mongodb-server is not installed, so not removed 0 upgraded, 0 newly installed, 0 to remove and 406 not upgraded. -----when trying to remove, when i again give mongo it showing the vesion:MongoDB shell version: 2.0.1

      – jyothi
      Jun 6 '12 at 10:02













    • That is fine; as I said, some of those commands may fail, depending on which packages you have installed. Those particular errors show that you did not have the standard Ubuntu MongoDB packages installed.

      – David Edwards
      Jun 6 '12 at 10:07











    • Have you run the second command to remove the 10gen packages? If that removes nothing too, and you can still run the mongo client, then you must have done a manual install and you will have to delete by hand.

      – David Edwards
      Jun 6 '12 at 10:30











    • can i know how to install or to update mongo db to 2.0.5 from 2.0.1

      – jyothi
      Jun 6 '12 at 10:59













    • Installing the 10gen packages as described in my answer will give you 2.0.6. Previous versions are available for download and manual install from the MongoDB website, but I strongly suggest you stick to the packaged versions.

      – David Edwards
      Jun 6 '12 at 11:15



















    maisapride1@maisapride1:/$ sudo apt-get purge mongodb mongodb-clients mongodb-server mongodb-dev Reading package lists... Done Building dependency tree Reading state information... Done Package mongodb is not installed, so not removed Package mongodb-clients is not installed, so not removed Package mongodb-dev is not installed, so not removed Package mongodb-server is not installed, so not removed 0 upgraded, 0 newly installed, 0 to remove and 406 not upgraded. -----when trying to remove, when i again give mongo it showing the vesion:MongoDB shell version: 2.0.1

    – jyothi
    Jun 6 '12 at 10:02







    maisapride1@maisapride1:/$ sudo apt-get purge mongodb mongodb-clients mongodb-server mongodb-dev Reading package lists... Done Building dependency tree Reading state information... Done Package mongodb is not installed, so not removed Package mongodb-clients is not installed, so not removed Package mongodb-dev is not installed, so not removed Package mongodb-server is not installed, so not removed 0 upgraded, 0 newly installed, 0 to remove and 406 not upgraded. -----when trying to remove, when i again give mongo it showing the vesion:MongoDB shell version: 2.0.1

    – jyothi
    Jun 6 '12 at 10:02















    That is fine; as I said, some of those commands may fail, depending on which packages you have installed. Those particular errors show that you did not have the standard Ubuntu MongoDB packages installed.

    – David Edwards
    Jun 6 '12 at 10:07





    That is fine; as I said, some of those commands may fail, depending on which packages you have installed. Those particular errors show that you did not have the standard Ubuntu MongoDB packages installed.

    – David Edwards
    Jun 6 '12 at 10:07













    Have you run the second command to remove the 10gen packages? If that removes nothing too, and you can still run the mongo client, then you must have done a manual install and you will have to delete by hand.

    – David Edwards
    Jun 6 '12 at 10:30





    Have you run the second command to remove the 10gen packages? If that removes nothing too, and you can still run the mongo client, then you must have done a manual install and you will have to delete by hand.

    – David Edwards
    Jun 6 '12 at 10:30













    can i know how to install or to update mongo db to 2.0.5 from 2.0.1

    – jyothi
    Jun 6 '12 at 10:59







    can i know how to install or to update mongo db to 2.0.5 from 2.0.1

    – jyothi
    Jun 6 '12 at 10:59















    Installing the 10gen packages as described in my answer will give you 2.0.6. Previous versions are available for download and manual install from the MongoDB website, but I strongly suggest you stick to the packaged versions.

    – David Edwards
    Jun 6 '12 at 11:15







    Installing the 10gen packages as described in my answer will give you 2.0.6. Previous versions are available for download and manual install from the MongoDB website, but I strongly suggest you stick to the packaged versions.

    – David Edwards
    Jun 6 '12 at 11:15















    25














    To completely remove MongoDB from a system, you must remove the MongoDB applications themselves, the configuration files, and any directories containing data and logs. The following section guides you through the necessary steps.





    1. Stop MongoDB



      Stop the mongod process by issuing the following command:



      sudo service mongod stop



    2. Remove Packages



      Remove any MongoDB packages that you had previously installed.



      sudo apt-get purge mongodb-org*



    3. Remove Data Directories.



      Remove MongoDB databases and log files.



      sudo rm -r /var/log/mongodb /var/lib/mongodb







    share|improve this answer






























      25














      To completely remove MongoDB from a system, you must remove the MongoDB applications themselves, the configuration files, and any directories containing data and logs. The following section guides you through the necessary steps.





      1. Stop MongoDB



        Stop the mongod process by issuing the following command:



        sudo service mongod stop



      2. Remove Packages



        Remove any MongoDB packages that you had previously installed.



        sudo apt-get purge mongodb-org*



      3. Remove Data Directories.



        Remove MongoDB databases and log files.



        sudo rm -r /var/log/mongodb /var/lib/mongodb







      share|improve this answer




























        25












        25








        25







        To completely remove MongoDB from a system, you must remove the MongoDB applications themselves, the configuration files, and any directories containing data and logs. The following section guides you through the necessary steps.





        1. Stop MongoDB



          Stop the mongod process by issuing the following command:



          sudo service mongod stop



        2. Remove Packages



          Remove any MongoDB packages that you had previously installed.



          sudo apt-get purge mongodb-org*



        3. Remove Data Directories.



          Remove MongoDB databases and log files.



          sudo rm -r /var/log/mongodb /var/lib/mongodb







        share|improve this answer















        To completely remove MongoDB from a system, you must remove the MongoDB applications themselves, the configuration files, and any directories containing data and logs. The following section guides you through the necessary steps.





        1. Stop MongoDB



          Stop the mongod process by issuing the following command:



          sudo service mongod stop



        2. Remove Packages



          Remove any MongoDB packages that you had previously installed.



          sudo apt-get purge mongodb-org*



        3. Remove Data Directories.



          Remove MongoDB databases and log files.



          sudo rm -r /var/log/mongodb /var/lib/mongodb








        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited May 2 '18 at 7:57









        David Foerster

        28.4k1366111




        28.4k1366111










        answered May 17 '16 at 11:53









        BhaveshBhavesh

        26132




        26132























            4














            Follow the steps:





            1. Remove lock file



              sudo rm /var/lib/mongodb/mongod.lock



            2. Repair mongodb



              mongod --repair



            3. Start mongodb



              sudo service mongodb start



            4. Start mongo console



              mongo







            share|improve this answer


























            • @stumblebee: Please watch out for edit suggestions like this one! The service name is indeed mongodb as in the original version and you can verify that via the package file list.

              – David Foerster
              May 2 '18 at 8:01


















            4














            Follow the steps:





            1. Remove lock file



              sudo rm /var/lib/mongodb/mongod.lock



            2. Repair mongodb



              mongod --repair



            3. Start mongodb



              sudo service mongodb start



            4. Start mongo console



              mongo







            share|improve this answer


























            • @stumblebee: Please watch out for edit suggestions like this one! The service name is indeed mongodb as in the original version and you can verify that via the package file list.

              – David Foerster
              May 2 '18 at 8:01
















            4












            4








            4







            Follow the steps:





            1. Remove lock file



              sudo rm /var/lib/mongodb/mongod.lock



            2. Repair mongodb



              mongod --repair



            3. Start mongodb



              sudo service mongodb start



            4. Start mongo console



              mongo







            share|improve this answer















            Follow the steps:





            1. Remove lock file



              sudo rm /var/lib/mongodb/mongod.lock



            2. Repair mongodb



              mongod --repair



            3. Start mongodb



              sudo service mongodb start



            4. Start mongo console



              mongo








            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited May 15 '13 at 5:44









            Aditya

            9,353125589




            9,353125589










            answered May 15 '13 at 5:23









            user2123184user2123184

            411




            411













            • @stumblebee: Please watch out for edit suggestions like this one! The service name is indeed mongodb as in the original version and you can verify that via the package file list.

              – David Foerster
              May 2 '18 at 8:01





















            • @stumblebee: Please watch out for edit suggestions like this one! The service name is indeed mongodb as in the original version and you can verify that via the package file list.

              – David Foerster
              May 2 '18 at 8:01



















            @stumblebee: Please watch out for edit suggestions like this one! The service name is indeed mongodb as in the original version and you can verify that via the package file list.

            – David Foerster
            May 2 '18 at 8:01







            @stumblebee: Please watch out for edit suggestions like this one! The service name is indeed mongodb as in the original version and you can verify that via the package file list.

            – David Foerster
            May 2 '18 at 8:01







            protected by Community Feb 7 at 6:01



            Thank you for your interest in this question.
            Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



            Would you like to answer one of these unanswered questions instead?



            Popular posts from this blog

            How to reconfigure Docker Trusted Registry 2.x.x to use CEPH FS mount instead of NFS and other traditional...

            is 'sed' thread safe

            How to make a Squid Proxy server?