← 返回命令列表

Linux command

mongod 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Start MongoDB server

mongod

Specify data directory

mongod --dbpath [/data/db]

Specify port

mongod --port [27017]

Bind to all interfaces

mongod --bind_ip_all

Enable authentication

mongod --auth

Use config file

mongod --config [/etc/mongod.conf]

Run as replica set

mongod --replSet [rs0]

Run as a daemon with logging

mongod --fork --logpath [/var/log/mongod.log]

说明

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.

参数

-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.

FAQ

What is the mongod command used for?

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.

How do I run a basic mongod example?

Run `mongod` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -f, --config _FILE_ do in mongod?

Configuration file path.