MongoDB Documentation, Release 3.0.4 To start MongoDB using all defaults, issue the following command at the system shell: Specify a Data Directory If you want mongod to store data files at a path other than /data/db you can specify a dbPath . The dbPath must exist before you start mongod . If it does not exist, create the directory and the permissions so that mongod can read and write data to this path. For more information on permissions, see the security operations documentation (page 431). To specify a dbPath for mongod to use as a data directory, use the --dbpath option. The following invocation will start a mongod instance and store data in the /srv/mongodb path mongod --dbpath /srv/mongodb/ mongod mongod --port 12345 Specify a TCP Port Only a single process can listen for connections on a network interface at a time. If you run multiple mongod processes on a single machine, or have other processes that must use this port, you must assign each a different port to listen on for client connections. To specify a port to mongod , use the --port option on the command line. The following command starts mongod listening on port 12345 : Use the default port number when possible, to avoid confusion. Start mongod as a Daemon To run a mongod process as a daemon (i.e. fork ), and write its output to a log file, use the --fork and --logpath options. You must create the log directory; however, mongod will create the log file if it does not exist. The following command starts mongod as a daemon and records log output to /var/log/mongodb.log . Additional Configuration Options For an overview of common configurations and common configuration deploy- ments. configurations for common use cases, see Run-time Database Configuration (page 192). In a clean shutdown a mongod completes all pending operations, flushes all data to data files, and closes all data files. Other shutdowns are unclean and can compromise the validity the data files. To ensure a clean shutdown, always shutdown mongod instances using one of the following methods: Use shutdownServer() Shut down the mongod from the mongo shell using the db.shutdownServer() method as follows: mongod --fork --logpath /var/log/mongodb.log Stop mongod Processes use admin db.shutdownServer() Calling the same method from a control script accomplishes the same result. For systems with authorization enabled, users may only issue db.shutdownServer() when authenticated to the admin database or via the localhost interface on systems without authentication enabled. 225 5.2. Administration Tutorials