Home >Database >Mysql Tutorial >MongoDB常用操作命令整理

MongoDB常用操作命令整理

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-07 15:53:381176browse

mongodb操作命令(注意所有db.开头命令,请先使用use到指定db再操作)

mongodb操作命令(注意所有db.开头命令,请先使用use到指定db再操作)
连接操作数据库:
/usr/local/mongodb-3.0.4/bin/mongo 192.168.6.118:30000/admin

添加分片服务器:
db.runCommand({"addshard":"192.168.6.118:27017"})

设置分片数据库:
db.runCommand({"enablesharding": "qiaodazhao"})
db.runCommand({"enablesharding": "testdb"})

使用数据库:
use qiaodazhao

设置表分片基于字段hash:
sh.shardCollection("qiaodazhao.resume_meta_data",{_id:"hashed"})
sh.shardCollection("testdb.resumetemp",{_id:"hashed"})

设置表分片基于字段(注意以下两种方式作用相同):
db.runCommand({"shardcollection":"qiaodazhao.things", "key":{"_id":1}})
sh.shardCollection("qiaodazhao.things",{_id:1})

打印数据库分片信息:
db.printShardingStatus()

打印服务器信息:
db.serverStatus()

表格数据总量统计:
db.table.count()

创建表索引:
db.resume_meta_data.ensureIndex({"org_name":1},{"background":true})

查看表索引:
db.resume_meta_data.getIndexes()

MongoDB 3.0 正式版发布下载 

CentOS编译安装MongoDB

CentOS 编译安装 MongoDB与mongoDB的php扩展

CentOS 6 使用 yum 安装MongoDB及服务器端配置

Ubuntu 13.04下安装MongoDB2.4.3

MongoDB入门必读(概念与实战并重)

Ubunu 14.04下MongoDB的安装指南

《MongoDB 权威指南》(MongoDB: The Definitive Guide)英文文字版[PDF]

Nagios监控MongoDB分片集群服务实战

基于CentOS 6.5操作系统搭建MongoDB服务

MongoDB 的详细介绍:请点这里
MongoDB 的下载地址:请点这里

本文永久更新链接地址

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn