Configure and run MongoDB on Ubuntu/Debian

If you followed the procedure outlined in the previous section, a configuration file /etc/mongod.conf will have been auto-generated by the installation script. By default, data files will be placed in /var/lib/mongodb and log files in /var/log/mongodb/mongod.log:

You are now able to perform these operations:

Operation Command
Start | stop | restart the server sudo service mongod start|stop|restart
Get the server status sudo service mongod status
Access MongoDB via the shell (covered later) mongo --host 127.0.0.1:27017
Here you can see the server started, along with its status:
MongoDB ...

Get MongoDB 4 Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.