By adding the --fork
option in the command, MongoDB
will start in background.
For Example
mongod --fork --logpath /var/log/mongodb/mongod.log
Set database path
If you want to set the database path, use same command but add the --dbpath
option
mongod --fork --logpath /var/log/mongodb/mongod.log --dbpath "path/to/database/directory"