博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
mongoDB学习之旅(一)
阅读量:5061 次
发布时间:2019-06-12

本文共 3139 字,大约阅读时间需要 10 分钟。

 

 

首先自己去官网下载哦~ 我的是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

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

 

转载于:https://www.cnblogs.com/Toolo/p/4628958.html

你可能感兴趣的文章
[置顶] Android仿人人客户端(v5.7.1)——人人授权访问界面
查看>>
Eclipse 调试的时候Tomcat报错启动不了
查看>>
【安卓5】高级控件——拖动条SeekBar
查看>>
ES6内置方法find 和 filter的区别在哪
查看>>
Android入门之文件系统操作(二)文件操作相关指令
查看>>
Android实现 ScrollView + ListView无滚动条滚动
查看>>
java学习笔记之String类
查看>>
UVA 11082 Matrix Decompressing 矩阵解压(最大流,经典)
查看>>
jdk从1.8降到jdk1.7失败
查看>>
硬件笔记之Thinkpad T470P更换2K屏幕
查看>>
【知识库】-数据库_MySQL 的七种 join
查看>>
iOS开发——缩放图片
查看>>
HTTP之URL的快捷方式
查看>>
满世界都是图论
查看>>
配置链路聚合中极小错误——失之毫厘谬以千里
查看>>
代码整洁
查看>>
蓝桥杯-分小组-java
查看>>
Java基础--面向对象编程1(类与对象)
查看>>
Android Toast
查看>>
iOS开发UI篇—Quartz2D使用(绘制基本图形)
查看>>