Start mongod service at system startup
19,338
Solution 1
You can either put the command in your /etc/bashrc script under and if condition i.e. if the mongod process is not already running, then start it.
Other way is to modify your /etc/rc.local and add the command to start mongod in that file. It will start at bootup.
Solution 2
Use the following command to autostart mongodb when system start.
systemctl enable mongod.service
Related videos on Youtube
Author by
Don Diego
Passion for programming and frontend in general, degree in Computer Science
Updated on June 07, 2022Comments
-
Don Diego almost 2 years
I recently updated
mongodb
, and I run Linux Mint (an Ubuntu based system) and every time I start it up, i cannot use Robomongo because the servicemongod
is not automatically started; every time I need to open up a terminal and usesudo service mongod start
Is there a way to start
mongod
automatically at system start?-
molaga over 7 years
sudo systemctl enable mongod && sudo systemctl start mongod
-
-
Don Diego over 7 yearsat last I used the second option, since I opened
/etc/bash.bashrc
(I don't have abashrc
file) and I found it way too complex to edit. Thanks! -
Don Diego over 7 yearsthat's strange, it works on reboot, but ater turning off the pc and restarting it the day after, it doesn't work anymore. Don't know why!
-
Don Diego about 6 yearsthere's no systemctl on ubuntu (mint)
-
Harshal Yeole over 5 yearsWorks for debian
-
Don Diego about 4 yearsYeah, but I asked for linux mint, not for debian.
-
Navid almost 4 yearsI used this command but it seems run without any error message, however I typed "mongo" I got this error:MongoDB shell version v4.2.8 connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb 2020-07-12T19:33:16.990+0430 E QUERY [js] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
-
hdoitc about 3 years@PredatorX
systemctl start mongod
and after that:mongo
-
Eric almost 3 years@Don Diego I'm using ubuntu (mint), it has the
systemctl
command. -
Don Diego almost 2 years@Eric yeah thank you, I asked it 5 years ago.