MongoDB初学

参考:MongoDB 教程 | 菜鸟教程

安装

1.下载安装,从官网下载winows安装包,安装到d盘(注意路径)

2.由于我安装在d盘,所以在d盘创建文件夹data,里面创建db文件夹

3.启动方法:在D:\Program Files\MongoDB\Server\3.2\bin下双击mongod.exe,如下则显示正常:

2016-04-15T21:24:08.293+0800 I CONTROL  [initandlisten] MongoDB starting : pid=6276 port=27017 dbpath=D:\data\db\ 64-bit host=DESKTOP-LPJTSPF
2016-04-15T21:24:08.295+0800 I CONTROL  [initandlisten] targetMinOS: Windows Vista/Windows Server 2008
2016-04-15T21:24:08.295+0800 I CONTROL  [initandlisten] db version v3.2.5
2016-04-15T21:24:08.296+0800 I CONTROL  [initandlisten] git version: 34e65e5383f7ea1726332cb175b73077ec4a1b02
2016-04-15T21:24:08.296+0800 I CONTROL  [initandlisten] allocator: tcmalloc
2016-04-15T21:24:08.296+0800 I CONTROL  [initandlisten] modules: none
2016-04-15T21:24:08.296+0800 I CONTROL  [initandlisten] build environment:
2016-04-15T21:24:08.297+0800 I CONTROL  [initandlisten]     distarch: x86_64
2016-04-15T21:24:08.297+0800 I CONTROL  [initandlisten]     target_arch: x86_64
2016-04-15T21:24:08.297+0800 I CONTROL  [initandlisten] options: {}
2016-04-15T21:24:08.297+0800 I -        [initandlisten] Detected data files in D:\data\db\ created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2016-04-15T21:24:08.298+0800 W -        [initandlisten] Detected unclean shutdown - D:\data\db\mongod.lock is not empty.
2016-04-15T21:24:08.298+0800 W STORAGE  [initandlisten] Recovering data from the last clean checkpoint.
2016-04-15T21:24:08.299+0800 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=4G,session_max=20000,eviction=(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),
2016-04-15T21:24:08.464+0800 I CONTROL  [initandlisten]
2016-04-15T21:24:08.465+0800 I CONTROL  [initandlisten] ** WARNING: Insecure configuration, access control is not enabled and no --bind_ip has been specified.
2016-04-15T21:24:08.465+0800 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted,
2016-04-15T21:24:08.465+0800 I CONTROL  [initandlisten] **          and the server listens on all available network interfaces.
2016-04-15T21:24:08.465+0800 I CONTROL  [initandlisten]
2016-04-15T21:24:08.467+0800 I NETWORK  [HostnameCanonicalizationWorker] Starting hostname canonicalization worker
2016-04-15T21:24:08.467+0800 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory 'D:/data/db/diagnostic.data'
2016-04-15T21:24:08.468+0800 I NETWORK  [initandlisten] waiting for connections on port 27017
2016-04-15T21:24:09.023+0800 I FTDC     [ftdc] Unclean full-time diagnostic data capture shutdown detected, found interim file, some metrics may have been lost. OK
2016-04-15T21:24:19.975+0800 I NETWORK  [initandlisten] connection accepted from 127.0.0.1:13732 #1 (1 connection now open)

若一闪而过则因为默认在d盘下的data/db文件夹未找到。如果你不想将db放在d:/data/db下也可以指定db位置:

cmd 进入d盘,cd Program Files\MongoDB\Server\3.2\bin,mongod.exe dbpath 指定的位置

这样也可以开启数据库。

4.打开客户端。双击bin目录下的mongo.exe,若不闪退则启动成功。

5.测试:

> db
test
> 1+2
3
> db.runoob.insert({x:10})
WriteResult({ "nInserted" : 1 })
> db.runoob.find()
{ "_id" : ObjectId("5710e88c34bf37767b29a10e"), "x" : 10 }

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

相关文章

来自专栏跟着阿笨一起玩NET

c#实现打印功能

2662
来自专栏张善友的专栏

Mix 10 上的asp.net mvc 2的相关Session

Beyond File | New Company: From Cheesy Sample to Social Platform Scott Hansel...

2537
来自专栏魂祭心

原 canvas绘制clock

4034
来自专栏Ceph对象存储方案

Luminous版本PG 分布调优

Luminous版本开始新增的balancer模块在PG分布优化方面效果非常明显,操作也非常简便,强烈推荐各位在集群上线之前进行这一操作,能够极大的提升整个集群...

3095
来自专栏闻道于事

js登录滑动验证,不滑动无法登陆

js的判断这里是根据滑块的位置进行判断,应该是用一个flag判断 <%@ page language="java" contentType="text/html...

6708
来自专栏我和未来有约会

Silverlight第三方控件专题

这里我收集整理了目前网上silverlight第三方控件的专题,若果有所遗漏请告知我一下。 名称 简介 截图 telerik 商 RadC...

3985
来自专栏一个会写诗的程序员的博客

Spring Reactor 项目核心库Reactor Core

Non-Blocking Reactive Streams Foundation for the JVM both implementing a Reactiv...

2132
来自专栏Golang语言社区

【Golang语言社区】GO1.9 map并发安全测试

var m sync.Map //全局 func maintest() { // 第一个 YongHuomap := make(map[st...

4698
来自专栏大内老A

The .NET of Tomorrow

Ed Charbeneau(http://developer.telerik.com/featured/the-net-of-tomorrow/) Exciti...

31010
来自专栏java 成神之路

使用 NIO 实现 echo 服务器

4547

扫码关注云+社区