mongo简单操作

1、阿里云给mongo数据库添加访问ip
云服务器ECS---运行中---服务器--(右边)管理---本实例安全组--配置规则--公网入方向--克隆--ip--ok




删除数据 db.getCollection('bs_live_msg').remove({"insertTime":{"$lt":new Date("2016/12/01")}}


db.getCollection('bs_user').find({userNickName:'游客MY55VOg0'})


模糊查询db.UserInfo.find({userName :/A/})


LIKE "A%"模糊查询  db.UserInfo.find({userName :/^A/})


删除
db.bs_user.remove({'userNickName':/^游客/})




db.bs_user.group({
 keyf : function(doc){
var date = new Date(doc.insertTime);
var dateKey = ""+date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate();
return {'day':dateKey}; 
}, 
condition:{userNickName:/^游客/,userType:1},
 initial : {"count":0}, 
 reduce : function Reduce(doc, out) {
            if(doc.userNickName){
out.count +=1;
            }
}
});






数据备份 


cd  F:\Program Files\MongoDB\Server\3.2\bin (到mongo的安装目录下)


单个数据库备份
123.123.123.xxx:27010  ip:端口
hzvip-test数据库名  
mongodump -h 123.123.123.xxx:27017  -d liveshow-ede-sc -o e:/ede


单个数据库备份还原
mongorestore -h 123.123.123.xxx:27017 -d liveshow-ede-sc e:/ede --drop


mongorestore -h 123.123.123.xxx :27017 -d liveshow-data e:/ede/liveshow-ede-sc


单collection备份
mongoexport -h 123.123.123.xxx:27010 -d hzvip-test -c bms_employees  -o e:\bms_employees.data


单collection还原
mongoimport -h 123.123.123.xxx:27010 -d hzvip-test -c bms_employees   e:\bms_employees.data







评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值