mongoDB學習之旅(一)

來源:互聯網
上載者:User

標籤:

 

 

首先自己去https://www.mongodb.org/官網下載哦~ 我的是64位的

安裝就簡單講下吧...下載個安裝包, 隨便安裝, 只要你找到的...

cmd進去你的安裝目錄下/bin檔案夾...簡單的很...

 

1. 找到“mongodb”的路徑,然後運行mongod開啟命令,同時用--dbpath指定資料存放地點為“db”檔案夾
D:\MongoDB\server\bin>mongod --dbpath=D:\MongoDB\data
2015-07-07T23:43:19.739+0800 I CONTROL Hotfix KB2731284 or later update is not installed, will zero-out data files
2015-07-07T23:43:19.801+0800 I JOURNAL [initandlisten] journal dir=D:\MongoDB\data\journal
2015-07-07T23:43:19.802+0800 I JOURNAL [initandlisten] recover : no journal files present, no recovery needed
2015-07-07T23:43:19.837+0800 I JOURNAL [durability] Durability thread started
2015-07-07T23:43:19.837+0800 I JOURNAL [journal writer] Journal writer thread started
2015-07-07T23:43:19.842+0800 I CONTROL [initandlisten] MongoDB starting : pid=6564 port=27017 dbpath=D:\MongoDB\data 64-bit host=Toolo
2015-07-07T23:43:19.842+0800 I CONTROL [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2015-07-07T23:43:19.842+0800 I CONTROL [initandlisten] db version v3.0.4
2015-07-07T23:43:19.843+0800 I CONTROL [initandlisten] git version: 0481c958daeb2969800511e7475dc66986fa9ed5
2015-07-07T23:43:19.878+0800 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1m-fips 19 Mar 2015
2015-07-07T23:43:19.878+0800 I CONTROL [initandlisten] build info: windows sys.getwindowsversion(major=6, minor=1, build=7601, platform=2, service_pack=‘Service Pack 1‘) BOOST_LIB_VERSION=1_49
2015-07-07T23:43:19.879+0800 I CONTROL [initandlisten] allocator: tcmalloc
2015-07-07T23:43:19.879+0800 I CONTROL [initandlisten] options: { storage: { dbPath: "D:\MongoDB\data" } }
2015-07-07T23:43:19.881+0800 I INDEX [initandlisten] allocating new ns file D:\MongoDB\data\local.ns, filling with zeroes...
2015-07-07T23:43:20.136+0800 I STORAGE [FileAllocator] allocating new datafile D:\MongoDB\data\local.0, filling with zeroes...
2015-07-07T23:43:20.136+0800 I STORAGE [FileAllocator] creating directory D:\MongoDB\data\_tmp
2015-07-07T23:43:20.425+0800 I STORAGE [FileAllocator] done allocating datafile D:\MongoDB\data\local.0, size: 64MB, took 0.286 secs
2015-07-07T23:43:20.536+0800 I NETWORK [initandlisten] waiting for connections on port 27017


2. 再開啟一個cmd視窗,進入到bin目錄下...
D:\MongoDB\server\bin>mongo
2015-07-07T23:58:30.882+0800 I CONTROL Hotfix KB2731284 or later update is not installed, will zero-out data files
MongoDB shell version: 3.0.4
connecting to: test

預設進入test資料庫


3.插入資料:
>db.Person.insert({"name":"helloword","age":"23"});
WriteResult({ "nInserted" : 1 })

提示插入成功!

4.查詢資料
  4.1 全部查詢
  > db.Person.find();
  { "_id" : ObjectId("559bf7cb15c09e490e77d072"), "name" : "feiazi", "age" : "22" }
  { "_id" : ObjectId("559bf7da15c09e490e77d073"), "name" : "helloword", "age" : "23" }
  { "_id" : ObjectId("559bf7fa15c09e490e77d074"), "name" : "luojun", "age" : "22" }
  4.2 條件查詢
  > db.Person.find({"name":"luojun"});
  { "_id" : ObjectId("559bf7fa15c09e490e77d074"), "name" : "luojun", "age" : "22" }

 

 

 

PS: 建議配置下系統的path環境變數, 這樣就不用每次就需要cmd進mongoDB的安裝目錄下bin檔案夾了...

 

夜深了, 我睡覺了... 喜歡一起學習的, 可以關注哦!

 

 

 

 

來源:http://www.cnblogs.com/huangxincheng/archive/2012/02/18/2356595.html

謝謝你的分享, 讓我學到很多....

 

mongoDB學習之旅(一)

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.