MongoDB安装
官方下载地址:http://www.mongodb.org/downloads
下载后解压到E\MongoDB
启动Mongo服务:
打开CMD窗口,按照如下方式输入命令:
C:\> cd \my_mongo_dir\bin
C:\my_mongo_dir\bin> mongod
配置成功后会看到如下提示:
Mon Jun 13 03:32:32 [initandlisten] db version v1.8.1, pdfile version 4.5
Mon Jun 13 03:32:32 [initandlisten] git version: a429cd4f535b2499cc4130b06ff7c26f41c00f04
Mon Jun 13 03:32:32 [initandlisten] build sys info: windows (5, 1, 2600, 2, 'Service Pack 3') BOOST_LIB_VERSION=1_35
Mon Jun 13 03:32:32 [initandlisten] waiting for connections on port 27017
Mon Jun 13 03:32:32 [websvr] web admin interface listening on port 28017
Mon Jun 13 03:33:23 [initandlisten] connection accepted from 127.0.0.1:8612 #1
在浏览器输入:http://localhost:27017/,如果看到如下就说明MongoDB服务已经成功启动
You are trying to access MongoDB on the native driver port. For http diagnostic access, add 1000 to the port number
运行CLIENT测试
打开CMD窗口,按照如下方式输入命令:
C:\> cd \my_mongo_dir\bin
C:\my_mongo_dir\bin> mongo
> // the mongo shell is a javascript shell connected to the db
> // by default it connects to database 'test' at localhost
> 3+3
6
> db
test
> // the first write will create the db:
> db.foo.insert( { a : 1 } )
> db.foo.find()
{ _id : ..., a : 1 }
> show dbs
...
> show collections
...