Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (6.1k points)

I have installed Mongopi from Github and it is working really fine after few amendments such as:

$ sudo chown 

$USER /data/db

But, mongod and mongo calls are not firm and they do not last for the next ssh session.

I follow this path: 

PATH=$PATH:/opt/mongo/bin/ & export PATH

So could you please tell me the process of initializing MongoDB at startup?

1 Answer

0 votes
by (11.7k points)

The process of setting up MongoDB raspberry pi is listed down below.

The first part of your question is related to the path:

If you want the to work, place it inside a script that gets executed every time you log in.

Mostly, there is a rc-file available for you in the shell home directory. Just type:

echo $SHELL

If you want to track the running shell, go to the home directory:

cd

Then open .(your shell)rc - file and if you are running bash open.bashrc

nano .bashrc

Now at the end of this file, add the path:

PATH=$PATH:/opt/mongo/bin export PATH

Now about the initialization part:

Download the script from here and edit it.

Go to line 50 and change the value of Deamon. Also, add a MongoDB user to make the server running. Go with by default option. 

After editing, move your file to /etc/init.d/mongodb in this way:

sudo mv init.d /etc/init.d/mongodb

Now add it to the system’s startup routine:

sudo update-rc.d mongodb defaults

I am answering by consider that you are a Debian user

control the service by:

sudo service mongodb start service mongodb status sudo service mongodb stop

This will automatically run on start-up and shutdown.

Browse Categories

...