实例:启动mongo数据库服务:mongod --dbpath 数据库目录

启动mongo数据库服务,在CMD中执行命令 即可

$ mongod --dbpath 数据库目录

本例将数据内容放在d盘根目录下db文件夹,因此写为 mongod --dbpath D:/db

实例:启动mongo数据库服务:mongod --dbpath 数据库目录_第1张图片

实例:启动mongo数据库服务:mongod --dbpath 数据库目录_第2张图片

回车后静止在如下界面,注意红框标记处,是mongo数据库可访问的端口,证明数据库服务已启动。

实例:启动mongo数据库服务:mongod --dbpath 数据库目录_第3张图片

查看db文件夹,里面自动生成了一些文件。

实例:启动mongo数据库服务:mongod --dbpath 数据库目录_第4张图片

 

附:代码框中是从CMD中截取的,标出的红色字体分别是数据目录服务端口

2019-03-10T06:20:54.593-0700 I CONTROL  [initandlisten] options: { storage: { dbPath: "D:\db" } }
2019-03-10T06:20:54.595-0700 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=3479M,session_max=20000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),compatibility=(release="3.0",require_max="3.0"),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),statistics_log=(wait=0),verbose=(recovery_progress),
2019-03-10T06:20:55.179-0700 I STORAGE  [initandlisten] WiredTiger message [1552224055:166488][488:140730618694112], txn-recover: Set global recovery timestamp: 0
2019-03-10T06:20:56.015-0700 I CONTROL  [initandlisten]
2019-03-10T06:20:56.015-0700 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2019-03-10T06:20:56.016-0700 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2019-03-10T06:20:56.016-0700 I CONTROL  [initandlisten]
2019-03-10T06:20:56.016-0700 I CONTROL  [initandlisten] ** WARNING: This server is bound to localhost.
2019-03-10T06:20:56.016-0700 I CONTROL  [initandlisten] **          Remote systems will be unable to connect to this server.
2019-03-10T06:20:56.016-0700 I CONTROL  [initandlisten] **          Start the server with --bind_ip

to specify which IP
2019-03-10T06:20:56.016-0700 I CONTROL  [initandlisten] **          addresses it should serve responses from, or with --bind_ip_all to
2019-03-10T06:20:56.017-0700 I CONTROL  [initandlisten] **          bind to all interfaces. If this behavior is desired, start the
2019-03-10T06:20:56.018-0700 I CONTROL  [initandlisten] **          server with --bind_ip 127.0.0.1 to disable this warning.
2019-03-10T06:20:56.018-0700 I CONTROL  [initandlisten]
2019-03-10T21:20:56.337+0800 I STORAGE  [initandlisten] createCollection: admin.system.version with provided UUID: 31d14889-7e34-4fe7-87b1-b32e5f79fa92
2019-03-10T21:20:56.803+0800 I COMMAND  [initandlisten] setting featureCompatibilityVersion to 3.6
2019-03-10T21:20:56.852+0800 I STORAGE  [initandlisten] createCollection: local.startup_log with generated UUID: ad88af14-b5fb-4343-9a64-b7da629cc70c
2019-03-10T21:20:57.585+0800 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory 'D:/db/diagnostic.data'
2019-03-10T21:20:57.600+0800 I STORAGE  [LogicalSessionCacheRefresh] createCollection: config.system.sessions with generated UUID: a2467dd0-c04d-4b98-bc94-c4c4e143633e
2019-03-10T21:20:57.612+0800 I NETWORK  [initandlisten] waiting for connections on port 27017
2019-03-10T21:20:57.935+0800 I INDEX    [LogicalSessionCacheRefresh] build index on: config.system.sessions properties: { v: 2, key: { lastUse: 1 }, name: "lsidTTLIndex", ns: "config.system.sessions", expireAfterSeconds: 1800 }
2019-03-10T21:20:57.935+0800 I INDEX    [LogicalSessionCacheRefresh]     building index using bulk method; build may temporarily use up to 500 megabytes of RAM
2019-03-10T21:20:58.073+0800 I INDEX    [LogicalSessionCacheRefresh] build index done.  scanned 0 total records. 0 secs
2019-03-10T21:20:58.074+0800 I COMMAND  [LogicalSessionCacheRefresh] command config.$cmd command: createIndexes { createIndexes: "system.sessions", indexes: [ { key: { lastUse: 1 }, name: "lsidTTLIndex", expireAfterSeconds: 1800 } ], $db: "config" } numYields:0 reslen:98 locks:{ Global: { acquireCount: { r: 2, w: 2 } }, Database: { acquireCount: { w: 2, W: 1 } }, Collection: { acquireCount: { w: 2 } } } protocol:op_msg 473ms

你可能感兴趣的:(web开发,nodejs,mongo)