LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

mongod

MongoDB database server daemon

TLDR

Start MongoDB server
$ mongod
copy
Specify data directory
$ mongod --dbpath [/data/db]
copy
Specify port
$ mongod --port [27017]
copy
Bind to all interfaces
$ mongod --bind_ip_all
copy
Enable authentication
$ mongod --auth
copy
Use config file
$ mongod --config [/etc/mongod.conf]
copy
Run as replica set
$ mongod --replSet [rs0]
copy
Run as a daemon with logging
$ mongod --fork --logpath [/var/log/mongod.log]
copy

SYNOPSIS

mongod [options]

DESCRIPTION

mongod is the MongoDB database server daemon. It handles data requests, manages data storage, and performs background management operations.The tool is the core database process. Supports replication, sharding, and authentication. Uses the WiredTiger storage engine by default.

PARAMETERS

-f, --config FILE

Configuration file path.
--dbpath PATH
Database directory path (default: /data/db).
--port PORT
Listening port number (default: 27017).
--bind_ip IP
Comma-separated list of IP addresses to bind.
--bind_ip_all
Bind to all IP addresses.
--auth
Enable authentication.
--replSet NAME
Replica set name.
--logpath FILE
Path for the log file. Required when using --fork.
--fork
Run the server as a background daemon.
--keyFile FILE
Path to shared key file for replica set/sharded cluster authentication. Implies --auth.
--wiredTigerCacheSizeGB SIZE
Maximum size of the WiredTiger internal cache in GB.
--help
Display help information.

CAVEATS

Requires proper storage configuration. Resource intensive. Needs careful security setup. When using --fork, --logpath must also be specified.

HISTORY

mongod is the MongoDB server process, the core component of MongoDB since its initial release in 2009.

SEE ALSO

Copied to clipboard
Kai