Database Commands数据库命令
All command documentation outlined below describes a command and its available parameters and provides a document template or prototype for each command. 下面列出的所有命令文档都描述了命令及其可用参数,并为每个命令提供了文档模板或原型。Some command documentation also includes the relevant 一些命令文档还包括相关的mongosh
helpers.mongosh
助手。
To run a command against the current database, use 要对当前数据库运行命令,请使用db.runCommand()
:db.runCommand()
:
db.runCommand( { <command> } )
To run an administrative command against the 要对admin
database, use db.adminCommand()
:admin
数据库运行管理命令,请使用db.adminCommand()
:
db.adminCommand( { <command> } )
For details on specific commands, including syntax and examples, click on the specific command to go to its reference page.有关特定命令的详细信息,包括语法和示例,请单击特定命令转到其参考页。
Command Syntax命令语法
When you run a database command, you specify the command as a document to 运行数据库命令时,将该命令指定为db.runCommand()
. db.runCommand()
的文档。The document's key is the command to run, and the value is typically supplied as 文档的键是要运行的命令,该值通常以1
. 1
的形式提供。The value does not affect the output of the command for example:该值不会影响命令的输出,例如:
db.runCommand( { hello: 1 } )
User Commands用户命令
Aggregation Commands聚合命令
aggregate | $group using an aggregation pipeline.$group 。 |
count | |
distinct | |
mapReduce |
Geospatial Commands地理空间命令
geoSearch |
Query and Write Operation Commands查询和写入操作命令
delete | |
find | |
findAndModify | |
getMore | |
insert | |
resetError | |
update |
Query Plan Cache Commands查询计划缓存命令
planCacheClear | |
planCacheClearFilters | |
planCacheListFilters | |
planCacheSetFilter |
Database Operations数据库操作
Authentication Commands身份验证命令
authenticate | |
logout |
User Management Commands用户管理命令
createUser | |
dropAllUsersFromDatabase | |
dropUser | |
grantRolesToUser | |
revokeRolesFromUser | |
updateUser | |
usersInfo |
Role Management Commands角色管理命令
createRole | |
dropRole | |
dropAllRolesFromDatabase | |
grantPrivilegesToRole | |
grantRolesToRole | |
invalidateUserCache | |
revokePrivilegesFromRole | |
revokeRolesFromRole | |
rolesInfo | |
updateRole |
Replication Commands复制命令
applyOps | |
hello | |
replSetAbortPrimaryCatchUp | |
replSetFreeze | |
replSetGetConfig | |
replSetGetStatus | |
replSetInitiate | |
replSetMaintenance | RECOVERING state.RECOVERING 状态。 |
replSetReconfig | |
replSetResizeOplog | |
replSetStepDown | |
replSetSyncFrom |
See also:
Replication for more information regarding replication.有关复制的详细信息。
Sharding Commands分片命令
abortReshardCollection | New in version 5.0. |
addShard | |
addShardToZone | |
balancerCollectionStatus | New in version 4.4. |
balancerStart | |
balancerStatus | |
balancerStop | |
checkShardingIndex | |
clearJumboFlag | jumbo flag for a chunk.jumbo 标志。 |
cleanupOrphaned | |
cleanupReshardCollection | New in version 5.0. |
commitReshardCollection | New in version 5.0. |
configureCollectionBalancing | New in version 5.3. |
enableSharding | |
flushRouterConfig | mongod / mongos instance to update its cached routing metadata.mongod /mongos 实例更新其缓存的路由元数据。 |
getShardMap | |
getShardVersion | |
isdbgrid | mongos .mongos 。 |
listShards | |
medianKey | splitVector .splitVector 。 |
moveChunk | |
movePrimary | |
moveRange | |
mergeChunks | |
refineCollectionShardKey | New in version 4.4. |
removeShard | |
removeShardFromZone | |
reshardCollection | New in version 5.0. |
setShardVersion | |
shardCollection | |
shardingState | mongod is a member of a sharded cluster.mongod 是否是分片集群的成员。 |
split | |
splitVector | |
unsetSharding | |
updateZoneKeyRange |
Session Commands会话命令
abortTransaction | New in version 4.0. |
commitTransaction | New in version 4.0. |
endSessions | |
killAllSessions | |
killAllSessionsByPattern | |
killSessions | |
refreshSessions | |
startSession |
Administration Commands管理命令
cloneCollectionAsCapped | |
collMod | |
compact | |
compactStructuredEncryptionData | |
convertToCapped | |
create | |
createIndexes | |
currentOp | |
drop | |
dropDatabase | |
dropConnections | |
dropIndexes | |
filemd5 | |
fsync | |
fsyncUnlock | |
getDefaultRWConcern | New in version 4.4. |
getClusterParameter | New in version 6.0. |
getParameter | |
killCursors | |
killOp | |
listCollections | |
listDatabases | |
listIndexes | |
logRotate | |
reIndex | |
renameCollection | |
rotateCertificates | |
setFeatureCompatibilityVersion | |
setIndexCommitQuorum | |
setClusterParameter | New in version 6.0. |
setParameter | |
setDefaultRWConcern | New in version 4.4. |
shutdown | mongod or mongos process.mongod 或mongos 进程。 |
Diagnostic Commands诊断命令
buildInfo | |
collStats | |
connPoolStats | |
connectionStatus | |
dataSize | |
dbHash | |
dbStats | |
driverOIDTest | |
explain | |
features | |
getCmdLineOpts | |
getLog | |
hostInfo | |
_isSelf | |
listCommands | mongod instance.mongod 实例提供的所有数据库命令。 |
lockInfo | mongod instances.mongod 实例。 |
netstat | mongos instances.mongos 实例。 |
ping | |
profile | |
serverStatus | |
shardConnPoolStats | connPoolStats instead.connPoolStats 。 |
top | mongod instance.mongod 实例中每个数据库的原始使用情况统计信息。 |
validate | |
whatsmyuri |
Free Monitoring Commands自由监视命令
setFreeMonitoring |
Auditing Commands审核命令
logApplicationMessage |