鍍金池/ 問答/數(shù)據(jù)庫/ mac終端上無法啟動mongo(3.6.2)

mac終端上無法啟動mongo(3.6.2)

【問題】
第一次使用MongoDB,安裝了但是無法通過終端進(jìn)入
搜索了相關(guān)資料也不知道問題所在何處

希望有人能稍微指點一下,感激不盡

【環(huán)境】
終端: mac os
MongoDB:3.6.2

【相關(guān)代碼】

登入MongoDB

himiMacBookPro:bin himi$ sudo mongod --port 27017 --dbpath /data/db

或者

himiMacBookPro:bin himi$ sudo mongod
mac的$path是設(shè)定好的了

↓得到下面

2018-02-12T21:01:38.228+0900 I CONTROL  [initandlisten] MongoDB starting : pid=24899 port=27017 dbpath=/data/db 64-bit host=himiMacBookPro.local
2018-02-12T21:01:38.228+0900 I CONTROL  [initandlisten] db version v3.6.2
2018-02-12T21:01:38.228+0900 I CONTROL  [initandlisten] git version: 489d177dbd0f0420a8ca04d39fd78d0a2c539420
2018-02-12T21:01:38.228+0900 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 0.9.8zc 15 Oct 2014
2018-02-12T21:01:38.228+0900 I CONTROL  [initandlisten] allocator: system
2018-02-12T21:01:38.228+0900 I CONTROL  [initandlisten] modules: none
2018-02-12T21:01:38.228+0900 I CONTROL  [initandlisten] build environment:
2018-02-12T21:01:38.228+0900 I CONTROL  [initandlisten]     distarch: x86_64
2018-02-12T21:01:38.229+0900 I CONTROL  [initandlisten]     target_arch: x86_64
2018-02-12T21:01:38.229+0900 I CONTROL  [initandlisten] options: { net: { port: 27017 }, storage: { dbPath: "/data/db" } }
2018-02-12T21:01:38.229+0900 I -        [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2018-02-12T21:01:38.229+0900 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=7680M,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-02-12T21:01:38.701+0900 I STORAGE  [initandlisten] WiredTiger message [1518436898:701666][24899:0x7fff75831300], txn-recover: Main recovery loop: starting at 6/4864
2018-02-12T21:01:38.826+0900 I STORAGE  [initandlisten] WiredTiger message [1518436898:826287][24899:0x7fff75831300], txn-recover: Recovering log 6 through 7
2018-02-12T21:01:38.921+0900 I STORAGE  [initandlisten] WiredTiger message [1518436898:921309][24899:0x7fff75831300], txn-recover: Recovering log 7 through 7
2018-02-12T21:01:39.125+0900 I CONTROL  [initandlisten]
2018-02-12T21:01:39.125+0900 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2018-02-12T21:01:39.125+0900 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2018-02-12T21:01:39.125+0900 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2018-02-12T21:01:39.125+0900 I CONTROL  [initandlisten]
2018-02-12T21:01:39.125+0900 I CONTROL  [initandlisten] ** WARNING: This server is bound to localhost.
2018-02-12T21:01:39.125+0900 I CONTROL  [initandlisten] **          Remote systems will be unable to connect to this server.
2018-02-12T21:01:39.125+0900 I CONTROL  [initandlisten] **          Start the server with --bind_ip <address> to specify which IP
2018-02-12T21:01:39.125+0900 I CONTROL  [initandlisten] **          addresses it should serve responses from, or with --bind_ip_all to
2018-02-12T21:01:39.125+0900 I CONTROL  [initandlisten] **          bind to all interfaces. If this behavior is desired, start the
2018-02-12T21:01:39.125+0900 I CONTROL  [initandlisten] **          server with --bind_ip 127.0.0.1 to disable this warning.
2018-02-12T21:01:39.125+0900 I CONTROL  [initandlisten]
2018-02-12T21:01:39.131+0900 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
2018-02-12T21:01:39.131+0900 I NETWORK  [initandlisten] waiting for connections on port 27017

這里會停留很長時間
照理說這個出來之后就應(yīng)該進(jìn)入mongo

↓但是過了很久會出現(xiàn)以下內(nèi)容

2018-02-12T21:06:39.153+0900 I STORAGE  [thread1] createCollection: config.system.sessions with generated UUID: c16f1163-15d8-4132-8a66-5a2e61d855b1
2018-02-12T21:06:39.238+0900 I INDEX    [thread1] build index on: config.system.sessions properties: { v: 2, key: { lastUse: 1 }, name: "lsidTTLIndex", ns: "config.system.sessions", expireAfterSeconds: 1800 }
2018-02-12T21:06:39.238+0900 I INDEX    [thread1]      building index using bulk method; build may temporarily use up to 500 megabytes of RAM
2018-02-12T21:06:39.260+0900 I INDEX    [thread1] build index done.  scanned 0 total records. 0 secs
2018-02-12T21:06:39.262+0900 I COMMAND  [thread1] 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: 1, w: 1 } }, Database: { acquireCount: { W: 1 } }, Collection: { acquireCount: { w: 1 } } } protocol:op_msg 115ms

然后就沒有其他內(nèi)容了.
等了半個小時也沒有變化

↓如果在上面的等待的時候control+c,會出現(xiàn)以下內(nèi)容

^C2018-02-12T22:04:41.601+0900 I CONTROL  [signalProcessingThread] got signal 2 (Interrupt: 2), will terminate after current cmd ends
2018-02-12T22:04:41.601+0900 I NETWORK  [signalProcessingThread] shutdown: going to close listening sockets...
2018-02-12T22:04:41.601+0900 I NETWORK  [signalProcessingThread] removing socket file: /tmp/mongodb-27017.sock
2018-02-12T22:04:41.603+0900 I FTDC     [signalProcessingThread] Shutting down full-time diagnostic data capture
2018-02-12T22:04:41.605+0900 I STORAGE  [signalProcessingThread] WiredTigerKVEngine shutting down
2018-02-12T22:04:41.803+0900 I STORAGE  [signalProcessingThread] shutdown: removing fs lock...
2018-02-12T22:04:41.805+0900 I CONTROL  [signalProcessingThread] now exiting
2018-02-12T22:04:41.805+0900 I CONTROL  [signalProcessingThread] shutting down with code:0

用了其他的看似是相關(guān)的命令,也不是很清楚這代表了什么

himiMacBookPro:~ himi$ sudo /usr/local/mongodb/bin/mongod
2018-02-12T20:31:44.076+0900 I CONTROL  [initandlisten] MongoDB starting : pid=24718 port=27017 dbpath=/data/db 64-bit host=himiMacBookPro.local
2018-02-12T20:31:44.076+0900 I CONTROL  [initandlisten] db version v3.6.2
2018-02-12T20:31:44.076+0900 I CONTROL  [initandlisten] git version: 489d177dbd0f0420a8ca04d39fd78d0a2c539420
2018-02-12T20:31:44.076+0900 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 0.9.8zc 15 Oct 2014
2018-02-12T20:31:44.076+0900 I CONTROL  [initandlisten] allocator: system
2018-02-12T20:31:44.076+0900 I CONTROL  [initandlisten] modules: none
2018-02-12T20:31:44.076+0900 I CONTROL  [initandlisten] build environment:
2018-02-12T20:31:44.076+0900 I CONTROL  [initandlisten]     distarch: x86_64
2018-02-12T20:31:44.076+0900 I CONTROL  [initandlisten]     target_arch: x86_64
2018-02-12T20:31:44.076+0900 I CONTROL  [initandlisten] options: {}
2018-02-12T20:31:44.078+0900 I STORAGE  [initandlisten] exception in initAndListen: DBPathInUse: Unable to lock the lock file: /data/db/mongod.lock (Resource temporarily unavailable). Another mongod instance is already running on the /data/db directory, terminating
2018-02-12T20:31:44.078+0900 I CONTROL  [initandlisten] now exiting
2018-02-12T20:31:44.078+0900 I CONTROL  [initandlisten] shutting down with code:100

【自己查找相關(guān)資料】

http://www.runoob.com/mongodb...
http://blog.csdn.net/xht555/a...
https://stackoverflow.com/que...
https://www.jianshu.com/p/116...

回答
編輯回答
巴扎嘿

mongod 是開啟數(shù)據(jù)庫進(jìn)程 并不是 mongo, 實際已經(jīng)啟動了數(shù)據(jù)庫, 你只需要再打開一個 terminal(終端) 然后輸入 mongo 就可以了.

mongo 是 mongodb 管理工具, mongod 是 mongodb 數(shù)據(jù)庫進(jìn)程.

2018年7月4日 02:16
編輯回答
怣人

你第一張圖 用mongod開機(jī)后得到下面這個信息并且一直停留在這個信息是正確的 然后你需要保持這個終端不動,重新開啟一個終端 輸入mongo

2018-02-12T21:01:38.228+0900 I CONTROL [initandlisten] MongoDB starting : pid=24899 port=27017 dbpath=/data/db 64-bit host=himiMacBookPro.local
2018-02-12T21:01:38.228+0900 I CONTROL [initandlisten] db version v3.6.2
2018-02-12T21:01:38.228+0900 I CONTROL [initandlisten] git version: 489d177dbd0f0420a8ca04d39fd78d0a2c539420
2018-02-12T21:01:38.228+0900 I CONTROL [initandlisten] OpenSSL version: OpenSSL 0.9.8zc 15 Oct 2014
2018-02-12T21:01:38.228+0900 I CONTROL [initandlisten] allocator: system
2018-02-12T21:01:38.228+0900 I CONTROL [initandlisten] modules: none
2018-02-12T21:01:38.228+0900 I CONTROL [initandlisten] build environment:
2018-02-12T21:01:38.228+0900 I CONTROL [initandlisten] distarch: x86_64
2018-02-12T21:01:38.229+0900 I CONTROL [initandlisten] target_arch: x86_64
2018-02-12T21:01:38.229+0900 I CONTROL [initandlisten] options: { net: { port: 27017 }, storage: { dbPath: "/data/db" } }
2018-02-12T21:01:38.229+0900 I - [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2018-02-12T21:01:38.229+0900 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=7680M,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-02-12T21:01:38.701+0900 I STORAGE [initandlisten] WiredTiger message 1518436898:701666, txn-recover: Main recovery loop: starting at 6/4864
2018-02-12T21:01:38.826+0900 I STORAGE [initandlisten] WiredTiger message 1518436898:826287, txn-recover: Recovering log 6 through 7
2018-02-12T21:01:38.921+0900 I STORAGE [initandlisten] WiredTiger message 1518436898:921309, txn-recover: Recovering log 7 through 7
2018-02-12T21:01:39.125+0900 I CONTROL [initandlisten]
2018-02-12T21:01:39.125+0900 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2018-02-12T21:01:39.125+0900 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2018-02-12T21:01:39.125+0900 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2018-02-12T21:01:39.125+0900 I CONTROL [initandlisten]
2018-02-12T21:01:39.125+0900 I CONTROL [initandlisten] ** WARNING: This server is bound to localhost.
2018-02-12T21:01:39.125+0900 I CONTROL [initandlisten] ** Remote systems will be unable to connect to this server.
2018-02-12T21:01:39.125+0900 I CONTROL [initandlisten] ** Start the server with --bind_ip <address> to specify which IP
2018-02-12T21:01:39.125+0900 I CONTROL [initandlisten] ** addresses it should serve responses from, or with --bind_ip_all to
2018-02-12T21:01:39.125+0900 I CONTROL [initandlisten] ** bind to all interfaces. If this behavior is desired, start the
2018-02-12T21:01:39.125+0900 I CONTROL [initandlisten] ** server with --bind_ip 127.0.0.1 to disable this warning.
2018-02-12T21:01:39.125+0900 I CONTROL [initandlisten]
2018-02-12T21:01:39.131+0900 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
2018-02-12T21:01:39.131+0900 I NETWORK [initandlisten] waiting for connections on port 27017
2018年5月3日 09:12