第一季

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

Install MongoDB in win7:  http://docs.mongodb.org/manual/tutorial/install-mongodb-on-windows/

(1)Download MongoDB zip , and unzip it.
(2)Config the mongoDB, config log and data dir.
      a. create a file "mongod.cfg" in the folder.
  b. add two items, more options please refer to the MongoDB manual:
        dbpath=D:\mongodb\data
        logpath=D:\mongodb\log
(3)Install the MongoDB as service, it's more convenient.
  Install Service: "D:\mongodb\bin\mongod.exe --config D:\mongodb\mongod.cfg --install"
  Start Service: "net start MongoDB"
  Stop Service: "net stop MongoDB"
  Remove Service: "D:\mongodb\bin\mongod.exe --remove"

Mongo Shell for MongoDB:  http://docs.mongodb.org/manual/tutorial/getting-started/

1. In cmd line, use "D:\mongodb\bin>start mongo.exe" to start the mongo shell.
2. "db": returns the name of the current database
3. "show dbs": display the list of databases
4. "use mydb": switch to db "mydb"
5. "help": or "xxx.help()" to show helps
------------------------------------------------------------------------------
6. "show collections": show the collections in this db
7. "db.things.insert(k)": insert docuemnt into the collection "things"

8. "db.things.find( { x : 4 } , { x:1, j : 2 } )":   后面的{x:1,j:2} 是投射,就是说找出来x=4的记录,并且展示出x和j的值。

posted on 2013-03-18 18:43  第一季  阅读(166)  评论(0编辑  收藏  举报