27

I installed mongodb for learning purpose, the problem I am facing is that it starts on system boot and consume resources even if not being used. I want it to be removed from system boot, how can I do this?

  • From how much resources are you talking about? – A.B. Sep 22 '15 at 13:03
  • 5
  • If you are using a recent version of ubuntu, you probably need to follow the instructions for systemd on how to "disable" a service: http://askubuntu.com/questions/19320/how-to-enable-or-disable-services?noredirect=1&lq=1 ; you can also "mask" a service if you want to completely disable the service. If you "disable" a service it will not automatically start at boot time. If you "mask" a service, it will not be able to be started and will be completely disabled. – mchid Jan 05 '17 at 20:14

5 Answers5

18

I can't test it at the moment, but I think this should work

 sudo update-rc.d mongodb disable

If this is not enough try this

 sudo update-rc.d -f mongodb remove
SpinningTop
  • 409
  • 2
  • 4
7

This worked for me and I'm using Ubuntu 18.04:

sudo systemctl disable mongod
Abdul Rehman
  • 171
  • 1
  • 2
  • With mongodb version v3.6.8 on linux mint 20 the service is called mongodb (and not just mongod), so I can disable it with sudo systemctl disable mongodb. – Peter T. Sep 02 '20 at 05:41
6

This is borrowed from this answer:

echo manual | sudo tee /etc/init/mongod.override
Zanna
  • 70,465
davelupt
  • 177
4

@davelupt's reference is great. However I guess the command should be

echo manual | sudo tee /etc/init/mongod.override

since the file for MongoDB under /etc/init is mongod.conf.

Robert
  • 141
  • 2
  • 1
    On 16.10 and 16.04, I'm showing /etc/init/mongodb.conf when I run either one of the following commands: dpkg -L mongodb-server | grep /etc/init/mongod or apt-file search /etc/init/mongod – mchid Jan 05 '17 at 20:30
0

For Ubuntu 18 and above use

$ sudo systemctl stop mongod

For earlier versions

$ sudo service mongod stop

For MacOS:

$ brew services stop mongodb-community@4.2

For Windows, Open CMD as Admin:

sc.exe delete MongoDB

More info can be found here

Nditah
  • 136