Start MongoDB Server from Command Prompt

Windows Users

Assuming that you installed MongoDB Server with default options, especially the installation folder as C:\Program Files\MongoDB\Server\4.0. Inside this folder, you have the bin directory containing mongod.exe.

Also assuming that the database path is: C:\data\db\

To start MongoDB Server in Windows, start Mongo Daemon (mongod.exe) using the following command:

ADVERTISEMENT
C:\> "C:\Program Files\MongoDB\Server\4.0\bin\mongod.exe"

Note that the program we are running is mongod.exe and not mongo.exe.

mongo.exe is used to start Mongo Shell, while mongod.exe is used to run Mongo Server.

C:\>"C:\Program Files\MongoDB\Server\4.0\bin\mongod.exe"
2018-10-10T11:02:43.496+0530 I CONTROL  [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2018-10-10T11:02:43.799+0530 I CONTROL  [initandlisten] MongoDB starting : pid=11716 port=27017 dbpath=C:\data\db\ 64-bit host=DESKTOP-QRVE3I1
2018-10-10T11:02:43.800+0530 I CONTROL  [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2018-10-10T11:02:43.801+0530 I CONTROL  [initandlisten] db version v4.0.3
2018-10-10T11:02:43.804+0530 I CONTROL  [initandlisten] git version: 7ea530946fa7880364d88c8d8b6026bbc9ffa48c
2018-10-10T11:02:43.804+0530 I CONTROL  [initandlisten] allocator: tcmalloc
2018-10-10T11:02:43.805+0530 I CONTROL  [initandlisten] modules: none
2018-10-10T11:02:43.805+0530 I CONTROL  [initandlisten] build environment:
2018-10-10T11:02:43.806+0530 I CONTROL  [initandlisten]     distmod: 2008plus-ssl
2018-10-10T11:02:43.807+0530 I CONTROL  [initandlisten]     distarch: x86_64
2018-10-10T11:02:43.807+0530 I CONTROL  [initandlisten]     target_arch: x86_64
2018-10-10T11:02:43.807+0530 I CONTROL  [initandlisten] options: {}
2018-10-10T11:02:43.809+0530 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=7612M,session_max=20000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),statistics_log=(wait=0),verbose=(recovery_progress),
2018-10-10T11:02:43.840+0530 I STORAGE  [initandlisten] WiredTiger message [1539149563:839654][11716:140703174245456], txn-recover: Set global recovery timestamp: 0
2018-10-10T11:02:43.849+0530 I RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
2018-10-10T11:02:43.874+0530 I CONTROL  [initandlisten]
2018-10-10T11:02:43.875+0530 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2018-10-10T11:02:43.875+0530 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2018-10-10T11:02:43.878+0530 I CONTROL  [initandlisten]
2018-10-10T11:02:43.878+0530 I CONTROL  [initandlisten] ** WARNING: This server is bound to localhost.
2018-10-10T11:02:43.879+0530 I CONTROL  [initandlisten] **          Remote systems will be unable to connect to this server.
2018-10-10T11:02:43.879+0530 I CONTROL  [initandlisten] **          Start the server with --bind_ip <address> to specify which IP
2018-10-10T11:02:43.879+0530 I CONTROL  [initandlisten] **          addresses it should serve responses from, or with --bind_ip_all to
2018-10-10T11:02:43.880+0530 I CONTROL  [initandlisten] **          bind to all interfaces. If this behavior is desired, start the
2018-10-10T11:02:43.880+0530 I CONTROL  [initandlisten] **          server with --bind_ip 127.0.0.1 to disable this warning.
2018-10-10T11:02:43.880+0530 I CONTROL  [initandlisten]
2018-10-10T11:02:43.881+0530 I STORAGE  [initandlisten] createCollection: admin.system.version with provided UUID: 0bf57dd0-b7c8-41da-8ddb-039c9fcf7c98
2018-10-10T11:02:43.899+0530 I COMMAND  [initandlisten] setting featureCompatibilityVersion to 4.0
2018-10-10T11:02:43.903+0530 I STORAGE  [initandlisten] createCollection: local.startup_log with generated UUID: 8102662d-18e5-4490-a9d5-696462810c13
2018-10-10T11:02:44.064+0530 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory 'C:/data/db/diagnostic.data'
2018-10-10T11:02:44.067+0530 I STORAGE  [LogicalSessionCacheRefresh] createCollection: config.system.sessions with generated UUID: 34b765ee-96c7-456b-9864-bfc5d53c1a22
2018-10-10T11:02:44.067+0530 I NETWORK  [initandlisten] waiting for connections on port 27017
2018-10-10T11:02:44.094+0530 I INDEX    [LogicalSessionCacheRefresh] build index on: config.system.sessions properties: { v: 2, key: { lastUse: 1 }, name: "lsidTTLIndex", ns: "config.system.sessions", expireAfterSeconds: 1800 }
2018-10-10T11:02:44.094+0530 I INDEX    [LogicalSessionCacheRefresh]     building index using bulk method; build may temporarily use up to 500 megabytes of RAM
2018-10-10T11:02:44.099+0530 I INDEX    [LogicalSessionCacheRefresh] build index done.  scanned 0 total records. 0 secs

The MongoDB Server has started successfully.

From the messages logged to the console, you can observe that:

  • Mongo Server is started as a process with process id (pid): 11716.
  • Mongo Server is listening at the port number: 27107. You can see at the end of logs [initandlisten] waiting for connections on port 27017.
  • Mongo Server is using the database present at the location C:\data\db\.

Do not close this Command Prompt window.

Now, you can connect to this server as clients from other Command Prompt windows.