Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Start mongod service at system startup

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 service mongod is not automatically started; every time I need to open up a terminal and use

sudo service mongod start

Is there a way to start mongod automatically at system start?

like image 416
Don Diego Avatar asked Nov 15 '16 08:11

Don Diego


People also ask

How do I manually start mongod?

Open up your command prompt and type mongod to start the MongoDB server.


2 Answers

Use the following command to autostart mongodb when system start.

systemctl enable mongod.service
like image 186
Yeshu Kochher Avatar answered Nov 16 '22 01:11

Yeshu Kochher


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.

like image 41
Farhad Avatar answered Nov 16 '22 00:11

Farhad