start mongodb code example

Example 1: how to restart mongodb server in ubuntu

sudo systemctl restart mongodb
# it will restarts running mongodb server

Example 2: start mongodb

sudo systemctl start mongod

Example 3: start mongodb service ubuntu

sudo systemctl start mongod
sudo systemctl stop mongod

Example 4: mongodb start server

sudo systemctl start mongodb

Example 5: start mongod

mongod --dbpath <file_path> --port <port>

Example 6: start mongodb in terminal

Start a terminal for your mongo server
Go to <mongodb-install-directory>/bin directory
Run the command./mongod
Start a terminal for your mongo shell
Go to <mongodb-install-directory>/bin directory
Run the command (make sure you put the name of the database)./mongo test

Tags:

Misc Example