首先自己去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

谢谢你的分享, 让我学到很多....

05-12 10:11