記錄一下mongoDB的使用

突然打算進軍node.js的開發領域,而且以此爲工做,因而一不當心boss上投了幾份簡歷,居然剛好有公司迴應,遂打算去試試,因而乎詳細的介紹了我前端的本質,以及進軍後端的決心,由於我想去試試呀,因此一不當心吹了小牛說本身能夠三天拿下mongoDB,雖然事實是我其實今天上午以前對他尚未足夠的瞭解,甚至從未接觸過任何一款數據庫產品,怎樣呢,吹出去的牛就是熬着夜通着宵也要把他實現,這池子水不知是深是淺,感興趣的小朋友能夠跟我一塊兒試試。下面我會盡量詳細的介紹學習mongo的全過程。
沒帶個人mac本子 因此暫時以Windows爲例html

安裝

  • 你們能夠根據本身的電腦型號自行下載
    https://www.mongodb.com/downl...前端

  • 建立數據目錄
    在任意的一個盤新建一個空目錄,我建立在了C盤裏 但並不建議哈,我只是想快速的走一下過場。如 C:/data/db (這個就是你的dbpath)node

c:\>mkdir data

c:\>cd data

c:\data>mkdir db

c:\data>cd db
  • 運行mongoDB服務
    找到mongodb安裝目錄,若是是自定義安裝的是 C:/Program Files/MongoDB/Server/3.4bin
    在bin文件運行git

bin文件裏邊通常用到的就兩個文件

mongod.exe用來啓動mongodb服務(啓動以後你的數據庫就可使用了的意思)

mongo.exe用來啓動進入數據庫(而後你就能夠命令操做數據庫的意思)
mongod --dbpath=剛建立的空目錄,如
mongod --dbpath=C:\data\db
2017-09-01T00:55:51.350-0700 I CONTROL  [initandlisten] MongoDB starting : pid=31752 port=27017 dbpath=c:\data\db 64-bit host=A001823-PC02
2017-09-01T00:55:51.350-0700 I CONTROL  [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2017-09-01T00:55:51.351-0700 I CONTROL  [initandlisten] db version v3.4.7
2017-09-01T00:55:51.351-0700 I CONTROL  [initandlisten] git version: cf38c1b8a0a8dca4a11737581beafef4fe120bcd
2017-09-01T00:55:51.352-0700 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.1u-fips  22 Sep 2016
2017-09-01T00:55:51.352-0700 I CONTROL  [initandlisten] allocator: tcmalloc
2017-09-01T00:55:51.352-0700 I CONTROL  [initandlisten] modules: none
2017-09-01T00:55:51.353-0700 I CONTROL  [initandlisten] build environment:
2017-09-01T00:55:51.353-0700 I CONTROL  [initandlisten]     distmod: 2008plus-ssl
2017-09-01T00:55:51.353-0700 I CONTROL  [initandlisten]     distarch: x86_64
2017-09-01T00:55:51.354-0700 I CONTROL  [initandlisten]     target_arch: x86_64
2017-09-01T00:55:51.354-0700 I CONTROL  [initandlisten] options: { storage: { dbPath: "c:\data\db" } }
2017-09-01T00:55:51.371-0700 I -        [initandlisten] Detected data files in c:\data\db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2017-09-01T00:55:51.372-0700 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=3534M,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),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
2017-09-01T00:55:52.349-0700 I CONTROL  [initandlisten]
2017-09-01T00:55:52.349-0700 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2017-09-01T00:55:52.350-0700 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2017-09-01T00:55:52.350-0700 I CONTROL  [initandlisten]
2017-09-01T15:55:52.594+0800 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory 'c:/data/db/diagnostic.data'
2017-09-01T15:55:52.596+0800 I NETWORK  [thread1] waiting for connections on port 27017
2017-09-01T16:14:55.905+0800 I CONTROL  [thread2] Ctrl-C signal
2017-09-01T16:14:55.905+0800 I CONTROL  [consoleTerminate] got CTRL_C_EVENT, will terminate after current cmd ends
2017-09-01T16:14:55.906+0800 I NETWORK  [consoleTerminate] shutdown: going to close listening sockets...
2017-09-01T16:14:55.906+0800 I NETWORK  [consoleTerminate] closing listening socket: 480
2017-09-01T16:14:55.907+0800 I NETWORK  [consoleTerminate] shutdown: going to flush diaglog...
2017-09-01T16:14:55.907+0800 I FTDC     [consoleTerminate] Shutting down full-time diagnostic data capture
2017-09-01T16:14:55.914+0800 I STORAGE  [consoleTerminate] WiredTigerKVEngine shutting down
2017-09-01T16:14:56.173+0800 I STORAGE  [consoleTerminate] shutdown: removing fs lock...
2017-09-01T16:14:56.173+0800 I CONTROL  [consoleTerminate] now exiting
2017-09-01T16:14:56.174+0800 I CONTROL  [consoleTerminate] shutting down with code:12

看到這個基本就是啓動成功而且堅挺了27017的端口waiting for connections on port 27017mongodb

這就挺好的能夠參考
http://www.cnblogs.com/imwtr/...數據庫

相關文章
相關標籤/搜索