Mongodb学习笔记--Mongodb安装(2)
来源:未知 责任编辑:责任编辑 发表时间:2014-05-20 18:34 点击:次
停止mongodb
[root@localhost ~]# service mongod stop
Stopping mongod: [ OK ]
重启mongodb
www.2cto.com
[root@localhost ~]# service mongod restart
Stopping mongod: [ OK ]
Starting mongod: all output going to: /var/log/mongo/mongod.log
forked process: 26420
[ OK ]
6)简单使用
查找
[root@localhost ~]# mongo
MongoDB shell version: 2.0.5
connecting to: test
> db.test.save( { a: 1})
> db.test.find()
{ "_id" : ObjectId("4fb83ca7698712e93dad12a7"), "a" : 1 }
插入
> doc = { author:'joe', created : new Date('03/28/2009')}
{ "author" : "joe", "created" : ISODate("2009-03-27T16:00:00Z") }
> db.test.insert(doc)
> db.test.find()
{ "_id" : ObjectId("4fb83ca7698712e93dad12a7"), "a" : 1 }
{ "_id" : ObjectId("4fb83e2c698712e93dad12a8"), "author" : "joe", "created" :
ISODate("2009-03-27T16:00:00Z") }
ISODate("2009-03-27T16:00:00Z") }
更新
> db.test.update({author : 'joe'}, {$inc: { check: 1000 }});
> db.test.find() www.2cto.com
{ "_id" : ObjectId("4fb83ca7698712e93dad12a7"), "a" : 1 }
{ "_id" : ObjectId("4fb83e2c698712e93dad12a8"), "author" : "joe", "check" : 1000,
"created" : ISODate("2009-03-27T16:00:00Z") }
"created" : ISODate("2009-03-27T16:00:00Z") }
删除
> db.test.remove({a:1});
> db.test.find()
{ "_id" : ObjectId("4fb83e2c698712e93dad12a8"), "author" : "joe", "check" : 1000,
"created" : ISODate("2009-03-27T16:00:00Z") }
"created" : ISODate("2009-03-27T16:00:00Z") }
作者 xiaozhenggang
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>