25 November, 2019

MongoDB

liton

472 views


Start MongoDB

sudo service mongod start

Verify that the mongod process has started successfully:

sudo service mongod status

As needed, you can stop the mongod process by issuing the following command:

sudo service mongod stop

Issue the following command to restart mongod:

sudo service mongod restart

Start a mongo shell on the same host machine as the mongod. You can run the mongo shell without any command-line options to connect to a mongod that is running on your localhost with default port 27017:

mongo

Use the following command to autostart mongodb when system start.

systemctl enable mongod.service

 

If faced any problem about returning status = 14

 because the permission setting on /var/lib/mongodb and /tmp/mongodb-27017.lock are wrong. You will have to change the owner to monogdb user

chown -R mongodb:mongodb /var/lib/mongodb
chown mongodb:mongodb /tmp/mongodb-27017.sock