当前位置:网站首页>MongoDB初始化操作
MongoDB初始化操作
2022-07-28 17:02:00 【水月清辉】
客户端登录
/opt/cloud/mongodb/bin/mongo -host x.xx.x.x --port 8635 -u rwuser -p xxxx --authenticationsDatabase admin
管理员账号登录
use admin
db.auth("dbadmin","xxx")
1,创建数据库
use pipeline
#查看数据库
show dbs
2,创建用户
use pipeline
db.createUser( {user: "pipeline",pwd: "123456",roles: [{role: "userAdminAnyDatabase", db: "pipeline"}],passwordDigestor: "server"})
db.grantRolesToUser("pipeline",[{role: "dbOwner",db: "cache"}]);
3,对实例启用分片
use admin
db.runCommand({enableSharding; "pipeline"})
4,创建集合,并对集合分片
use pipeline
db.createCollection("JobDetail")
sh.shardCollecton("pipeline.JobDetail", {"_id",1})
5,查看分片情况
db.getCollection("JobDetail").getShardDistribution();
6,创建索引
db.JobDetail.createIndex({"pipeline_id": 1},{background:true,name:"idx_pipeline_id"});
7,查询指定时间数据
db.JobDetail.find({"createTime": ($gt:ISOdate("2021-08-17 00:00:00Z"),$lt:ISOdate("2021-08-17 00:00:00Z"))}).count();
8,批量操作
db.JobDetail.find({"status": "pending"})
db.JobDetail.find({"status": "pending"}).forEach(
function(item){
db.JobDetail.update({"_id": item._id},{$set{"status":"completed"}})
}
)
边栏推荐
- “3·8女王节”限时大促竟让场观、视频号销量翻倍?
- Video Number Xiaobai starting operation guide
- Electrotechnics digital circuit self study notes 1.24
- Compilation principle learning notes 2 (Introduction to syntax analysis)
- 华为中兴在英国败诉,不交专利授权费将被禁售!
- $(document).Width() in WebView is a value
- Import the database backup of MySQL 8 into MySQL 5
- Food safety | will the salt content of bread exceed the standard? A few tips to teach you to eat bread correctly!
- ADS仿真 之 直流仿真示例
- Categories with good sales volume on the video Number
猜你喜欢

7-8 romantic profile (25 points) achievements + new problem solving ideas

2023年网络安全预算规划的五个关键考虑因素

硬件工程师成长之路(0)----认识元件

How to sharpen a knife simply by yourself

“云战略”将成为企业数字化转型的重要支柱

wordpress提示建立数据库连接时出错

centos使用docker运行mysql后,远程连接需要开放端口

互联智能,如何定义下一代网络变革

Xcode packaging IPA configuration manual configuration certificate

Digital filter (IV) -- converting analog filter into digital filter
随机推荐
Centos8 creates wordpress+mysql error reports according to the official website of docker
Tensorflow2.0 (XI) -- understanding LSTM network
mysql5.7压缩包安装教程
Application of Internet of things in smart city
Self study notes of electrical engineering, data and electricity 1.25
Digital filter (I) -- basic structure and matlab implementation of IIR and fir
Experience 5 minutes to develop wechat apps
Uniapp local packaging permission configuration problem
低码在数字化转型中扮演什么角色?
7-8 romantic profile (25 points) achievements + new problem solving ideas
Outdoor activities in hot weather are exquisite! Here comes the safety guide for citizens' fitness in midsummer
2023年网络安全预算规划的五个关键考虑因素
Compilation principle learning notes 2 (Introduction to syntax analysis)
这么多开源框架,该用哪个好?
Through private channels such as official account, direct the live broadcast of video number
Digital filter (V) -- design IIR filter
计算机组成原理核心知识点总结&面试笔试要点[通俗易懂]
视频号从每周2-3场到每天3场
com.mysql.jdbc.Driver 和 com.mysql.cj.jdbc.Driver的配置文件
体验5分钟开发微信小程序