Use the following options to view and control various aspects of your MongoDB Shell.使用以下选项查看和控制MongoDB Shell的各个方面。
General Options常规选项
--build-infoReturns a JSON-formatted document with information about your返回一个JSON格式的文档,其中包含有关mongoshbuild and driver dependencies.mongosh构建和驱动程序依赖关系的信息。Example: View Build Information示例:查看构建信息You can check the build information and driver dependencies of your您可以通过在终端运行以下命令来检查mongoshbinary by running the following command from your terminal:mongosh二进制文件的构建信息和驱动程序依赖关系:mongosh --build-infoThis command returns the following JSON-formatted document:此命令返回以下JSON格式的文档:{
version: '1.10.1',
distributionKind: 'packaged',
buildArch: 'x64',
buildPlatform: 'linux',
buildTarget: 'unknown',
buildTime: '2023-06-21T09:49:37.225Z',
gitVersion: '05ad91b4dd40382a13f27abe1ae8c3f9f52a38f7',
nodeVersion: 'v16.20.1',
opensslVersion: '3.1.1',
sharedOpenssl: true,
runtimeArch: 'x64',
runtimePlatform: 'darwin',
deps: {
nodeDriverVersion: '5.6.0'
}
}
--eval <javascript>Evaluates a JavaScript expression. You can use a single计算JavaScript表达式。您可以同时使用单个--evalargument or multiple--evalarguments together.--eval参数或多个--eval参数。Aftermongoshevaluates the--evalargument, it prints the results to your command line. If you use multiple--evalstatements,mongoshonly prints the results of the last--eval.mongosh计算完--eval参数后,会将结果打印到命令行。如果您使用多个--eval语句,mongosh只会打印最后一个--eval语句的结果。You can use the您可以将--jsonflag with--evalto returnmongoshresults in Extended JSON format.--json标志与--eval一起使用,以扩展json格式返回mongosh结果。mongoshsupports both--json=canonicaland--json=relaxedmodes.mongosh既支持--json=canonical模式,也支持--json=relaxed模式。If you omit the mode,如果省略模式,mongoshdefaults to thecanonicalmode.mongosh默认为canonical(规范)模式。The--jsonflag is mutually exclusive with--shell.--json标志与--shell是互斥的。Example: Format Output示例:格式化输出To get output suitable for automated parsing, use要获得适合自动解析的输出,请使用EJSON.stringify().EJSON.stringify()。mongosh --quiet --host rs0/centos1104 --port 27500 \
--eval "EJSON.stringify(rs.status().members.map( \
m => ({'id':m._id, 'name':m.name, 'stateStr':m.stateStr})));" \
| jqAfter parsing with用jq, the output resembles this:jq解析后,输出如下:[
{
"id": 0,
"name": "centos1104:27500",
"stateStr": "PRIMARY"
},
{
"id": 1,
"name": "centos1104:27502",
"stateStr": "SECONDARY"
},
{
"id": 2,
"name": "centos1104:27503",
"stateStr": "SECONDARY"
}
]Note
EJSONhas built in formatting options which may eliminate the need for a parser likejq. For example, the following code produces output that is formatted the same as above.EJSON内置了格式化选项,可以消除对jq等解析器的需求。例如,以下代码生成的输出格式与上述相同。mongosh --quiet --host rs0/centos1104 --port 27500 \
--eval "EJSON.stringify( rs.status().members.map( \
({ _id, name, stateStr }) => ({ _id, name, stateStr })), null, 2);"Example: Multiple --eval Arguments示例:多个--eval参数To get a list of collections in the要获取moviesDatabase, use multiple--evalstatements:moviesDatabase中的集合列表,请使用多个--eval语句:mongosh --quiet \
--eval 'use moviesDatabase' \
--eval 'show collections' \
mongodb://localhost/Example: --json Option示例:--json选项To return statistics about a collection in Extended JSON format using multiple要使用多个--evalstatements:--eval语句以扩展JSON格式返回有关集合的统计信息,请执行以下操作:mongosh --quiet --json=relaxed \
--eval 'use <database-name>' \
--eval 'db.<collection>.stats()' \
mongodb://localhost/
--file, -f <javascript>Runs a script from the command line without entering the MongoDB Shell console.从命令行运行脚本,而无需进入MongoDB Shell控制台。For additional details and an example, see Execute a Script From the Command Line.有关其他详细信息和示例,请参阅从命令行执行脚本。
--help, -hReturns information on the options and use of the MongoDB Shell.返回有关MongoDB Shell的选项和使用的信息。
--nodbPrevents the shell from connecting to any database instances.阻止shell连接到任何数据库实例。
--no-quietDisables the default禁用非交互式shell会话的默认--quietoption mode for non-interactive shell sessions. When specified,mongoshdisplays all messages during startup.--quiet选项模式。指定后,mongosh将在启动期间显示所有消息。
--norcPrevents the shell from sourcing and evaluating防止shell在启动时获取和评估~/.mongoshrc.json startup.~/.mongoshrc.js。
--quietSkips all messages during startup (such as welcome messages and startup warnings) and goes directly to the prompt.在启动过程中跳过所有消息(如欢迎消息和启动警告),直接进入提示。For non-interactive shell sessions, MongoDB enables对于非交互式shell会话,MongoDB默认启用--quietby default. You can disable this behavior using--no-quiet.--quiet。您可以使用--no-quiet禁用此行为。
--skipStartupWarningsPrevents防止mongoshfrom displaying server startup warnings when creating a session. To suppress all startup messages, use the--quietoption.mongosh在创建会话时显示服务器启动警告。要抑制所有启动消息,请使用--quiet选项。
--shellEnables the shell interface.启用shell界面。If you invoke the如果调用mongoshcommand and specify a JavaScript file as an argument, or use--evalto specify JavaScript on the command line, the--shelloption provides the user with a shell prompt after the file finishes executing.mongosh命令并指定一个JavaScript文件作为参数,或者在命令行上使用--eval指定JavaScript,则--shell选项会在文件执行完毕后为用户提供shell提示。The--shellflag is mutually exclusive with--json.--shell标志与--json是互斥的。
--verboseIncreases the verbosity of the shell output during the connection process and when running commands.在连接过程中和运行命令时增加shell输出的详细程度。
--versionReturns the MongoDB Shell release number.返回MongoDB Shell版本号。
Stable API Options稳定的API选项
--apiVersion <version number>Specifies the apiVersion.指定apiVersion。"1"is currently the only supported value."1"是目前唯一支持的值。
--apiStrictSpecifies that the server will respond with APIStrictError if your application uses a command or behavior outside of the Stable API.指定如果应用程序使用Stable API之外的命令或行为,则服务器将使用APIStrictError进行响应。If you specify如果指定--apiStrict, you must also specify--apiVersion.--apiStrict,则还必须指定--apiVersion。
--apiDeprecationErrorsSpecifies that the server will respond with APIDeprecationError if your application uses a command or behavior that is deprecated in the specified指定如果应用程序使用指定apiVersion.apiVersion中弃用的命令或行为,服务器将以APIDeprecationError响应。If you specify如果指定--apiDeprecationErrors, you must also specify--apiVersion.--apiDeprecationErrors,则还必须指定--apiVersion。
Connection Options连接选项
--host <hostname>Specifies the name of the host machine where the指定运行mongodormongosis running. If this is not specified, the MongoDB Shell attempts to connect to a MongoDB process running on the localhost.mongod或mongos的主机的名称。如果未指定,MongoDB Shell将尝试连接到在本地主机上运行的MongoDB进程。To connect to a replica set,为了连接到副本集,Specify the指定副本集名称和集成员的种子列表。使用以下表格:replica set nameand a seed list of set members. Use the following form:<replSetName>/<hostname1><:port>,<hostname2><:port>,<...>For TLS/SSL connections (对于TLS/SSL连接(--tls),--tls),The MongoDB Shell verifies that the hostname (specified in theMongoDB Shell验证主机名(在--hostoption or the connection string) matches theSAN(or, ifSANis not present, theCN) in the certificate presented by themongodormongos.--host选项或连接字符串中指定)是否与mongod或mongos提供的证书中的SAN(或者,如果SAN不存在,则为CN)匹配。If如果存在SANis present, the MongoDB Shell does not match against theCN. If the hostname does not match theSAN(orCN), the MongoDB Shell shell fails to connect.SAN,则MongoDB Shell与CN不匹配。如果主机名与SAN(或CN)不匹配,MongoDB Shell Shell将无法连接。
For DNS seedlist connections,对于DNS种子列表连接,Specify the connection protocol as将连接协议指定为mongodb+srv, followed by the DNS SRV hostname record and any options.mongodb+srv,然后指定DNS srv主机名记录和任何选项。TheauthSourceandreplicaSetoptions, if included in the connection string, overrides any corresponding DNS-configured options set in the TXT record.authSource和replicaSet选项(如果包含在连接字符串中)会覆盖TXT记录中设置的任何相应的DNS配置选项。Use of the使用mongodb+srv:connection string implicitly enables TLS / SSL (normally set withtls=true) for the client connection.mongodb+srv:连接字符串隐式地为客户端连接启用TLS/SSL(通常设置为TLS=true)。The TLS option can be turned off by setting可以通过在查询字符串中设置tls=falsein the query string.tls=false来关闭TLS选项。Example示例mongodb+srv://server.example.com/?connectionTimeoutMS=3000
--port <port>Specifies the port where the指定mongodormongosinstance is listening.mongod或mongos实例正在侦听的端口。If如果未指定--portis not specified, the MongoDB Shell attempts to connect to port27017.--port,MongoDB Shell将尝试连接到端口27017。
TLS OptionsTLS选项
--tlsEnables connection to a启用与启用了TLS/SSL支持的mongodormongosthat has TLS / SSL support enabled.mongod或mongos的连接。To learn more about TLS/SSL and MongoDB, see:要了解有关TLS/SSL和MongoDB的更多信息,请参阅:
--tlsCertificateKeyFile <filename>Specifies the指定包含.pemfile that contains both the TLS / SSL certificate and key formongosh. Specify the file name of the.pemfile using relative or absolute paths.mongosh的TLS/SSL证书和键的.pem文件。使用相对或绝对路径指定.pem文件的文件名。This option is required when using the当使用--tlsoption to connect to amongodormongosinstance that requires client certificates. That is, the MongoDB Shell presents this certificate to the server.--tls选项连接到需要客户端证书的mongod或mongos实例时,此选项是必需的。也就是说,MongoDB Shell将此证书呈现给服务器。Note
To learn more about TLS/SSL and MongoDB, see:要了解有关TLS/SSL和MongoDB的更多信息,请参阅:
--tlsCertificateKeyFilePassword <value>Specifies the password to de-crypt the certificate-key file (i.e.指定解密证书键文件的密码(即--tlsCertificateKeyFile).--tlsCertificateKeyFile)。Use the仅当证书键文件已加密时,才使用--tlsCertificateKeyFilePasswordoption only if the certificate-key file is encrypted. In all cases, the MongoDB Shell redacts the password from all logging and reporting output.--tlsCertificateKeyFilePassword选项。在所有情况下,MongoDB Shell都会从所有日志和报告输出中编辑密码。If the private key in the PEM file is encrypted and you do not specify the如果PEM文件中的私钥是加密的,并且您没有指定--tlsCertificateKeyFilePasswordoption; the MongoDB Shell prompts for a passphrase.--tlsCertificateKeyFilePassword选项;MongoDB Shell会提示输入密码。See TLS/SSL Certificate Passphrase.请参阅TLS/SSL证书密码。To learn more about TLS/SSL and MongoDB, see:要了解有关TLS/SSL和MongoDB的更多信息,请参阅:
--tlsCAFile <filename>Specifies the指定包含来自证书颁发机构的根证书链的.pemfile that contains the root certificate chain from the Certificate Authority..pem文件。This file is used to validate the certificate presented by the此文件用于验证mongod/mongosinstance.mongod/mongos实例提供的证书。Specify the file name of the使用相对或绝对路径指定.pemfile using relative or absolute paths..pem文件的文件名。To learn more about TLS/SSL and MongoDB, see:要了解有关TLS/SSL和MongoDB的更多信息,请参阅:
--tlsCRLFile <filename>Specifies the指定包含证书吊销列表的.pemfile that contains the Certificate Revocation List. Specify the file name of the.pemfile using relative or absolute paths..pem文件。使用相对或绝对路径指定.pem文件的文件名。To learn more about TLS/SSL and MongoDB, see:要了解有关TLS/SSL和MongoDB的更多信息,请参阅:
--tlsAllowInvalidHostnamesDisables the validation of the hostnames in the certificate presented by the禁用mongod/mongosinstance.mongod/mongos实例提供的证书中主机名的验证。Allows the MongoDB Shell to connect to MongoDB instances even if the hostname in the server certificates do not match the server's host.允许MongoDB Shell连接到MongoDB实例,即使服务器证书中的主机名与服务器的主机不匹配。To learn more about TLS/SSL and MongoDB, see:要了解有关TLS/SSL和MongoDB的更多信息,请参阅:
--tlsAllowInvalidCertificatesNew in version 4.2.在版本4.2中新增。Bypasses the validation checks for the certificates presented by the绕过mongod/mongosinstance and allows connections to servers that present invalid certificates.mongod/mongos实例提供的证书的验证检查,并允许连接到提供无效证书的服务器。Note
Starting in MongoDB 4.0, if you specify从MongoDB 4.0开始,如果在使用x.509身份验证时指定--tlsAllowInvalidCertificateswhen using x.509 authentication, an invalid certificate is only sufficient to establish a TLS / SSL connection but is insufficient for authentication.--tlsAllowInvalidCertificates,则无效证书仅足以建立TLS/SSL连接,但不足以进行身份验证。Warning
Although available, avoid using the虽然可用,但如果可能的话,请避免使用--tlsAllowInvalidCertificatesoption if possible. If the use of--tlsAllowInvalidCertificatesis necessary, only use the option on systems where intrusion is not possible.--tlsAllowInvalidCertificates选项。如果需要使用--tlsAllowInvalidCertificates,请仅在不可能发生入侵的系统上使用该选项。If the MongoDB Shell shell (and other MongoDB Tools) runs with the如果MongoDB Shell Shell(和其他MongoDB工具)使用--tlsAllowInvalidCertificatesoption, the shell (and other MongoDB Tools) do not attempt to validate the server certificates.--tlsAllowInvalidCertificates选项运行,则Shell(和其它MongoDB工具)不会尝试验证服务器证书。This creates a vulnerability to expired这为过期的mongodandmongoscertificates as well as to foreign processes posing as validmongodormongosinstances.mongod和mongos证书以及冒充有效mongod或mongos实例的外部进程创建了一个漏洞。If you only need to disable the validation of the hostname in the TLS / SSL certificates, see如果只需要禁用TLS/SSL证书中的主机名验证,请参阅--tlsAllowInvalidHostnames.--tlsAllowInvalidHostnames。To learn more about TLS/SSL and MongoDB, see:要了解有关TLS/SSL和MongoDB的更多信息,请参阅:
--tlsCertificateSelector <parameter>=<value>Available on Windows and macOS as an alternative to可在Windows和macOS上作为--tlsCertificateKeyFile.--tlsCertificateKeyFile的替代方案。Important
Windows and Importing Private KeysWindows和导入私钥When you import your private key, you must mark it as exportable. The Windows Certificate Import Wizard doesn't check this option by default.导入私钥时,必须将其标记为可导出。默认情况下,Windows“证书导入向导”不选中此选项。
The--tlsCertificateKeyFileand--tlsCertificateSelectoroptions are mutually exclusive. You can only specify one.--tlsCertificateKeyFile和--tlsCertificateSelector选项是互斥的。您只能指定一个。Specifies a certificate property in order to select a matching certificate from the operating system's certificate store.指定证书属性,以便从操作系统的证书存储中选择匹配的证书。--tlsCertificateSelectoraccepts an argument of the format接受格式为<property>=<value>where the property can be one of the following:<property>=<value>的参数,其中属性可以是以下之一:Property属性Value type值类型Description描述subjectASCII stringASCII字符串Subject name or common name on certificate证书上的主题名称或通用名称thumbprinthex string A sequence of bytes, expressed as hexadecimal, used to identify a public key by its SHA-1 digest.以十六进制表示的字节序列,用于通过SHA-1摘要标识公钥。Thethumbprintis sometimes referred to as afingerprint.thumbprint有时被称为fingerprint。When using the system SSL certificate store, OCSP (Online Certificate Status Protocol) is used to validate the revocation status of certificates.使用系统SSL证书存储时,OCSP(在线证书状态协议)用于验证证书的吊销状态。
--tlsDisabledProtocols <string>Disables the specified TLS protocols. The option recognizes the following protocols:禁用指定的TLS协议。该选项可识别以下协议:TLS1_0TLS1_1TLS1_2(Starting in version 4.0.4, 3.6.9, 3.4.24)(从4.0.4、3.6.9、3.4.24版本开始)TLS1_3On macOS, you cannot disable在macOS上,您无法禁用TLS1_1and leave bothTLS1_0andTLS1_2enabled. You must also disable at least one of the other two; for example,TLS1_0,TLS1_1.TLS1_1并同时启用TLS1_0和TLS1_2。您还必须禁用其他两个选项中的至少一个;例如,TLS1_0、TLS1_1。To list multiple protocols, specify as a comma separated list of protocols. For example要列出多个协议,请指定为逗号分隔的协议列表。例如TLS1_0,TLS1_1.TLS1_0,TLS1_1。The specified disabled protocols overrides any default disabled protocols.指定的禁用协议会覆盖任何默认禁用协议。
Starting in version 4.0, MongoDB disables the use of TLS 1.0 if TLS 1.1+ is available on the system.从4.0版本开始,如果系统上有TLS 1.1+可用,MongoDB将禁用TLS 1.0。To enable the disabled TLS 1.0, specify要启用已禁用的noneto--tlsDisabledProtocols.TLS 1.0,请在--tlsDisabledProtocols中指定none。
--tlsUseSystemCAAllows允许mongoshto load TLS certificates already available to the operating system's certificate authority without explicitly specifying the certificates to the shell. You cannot turn off this behavior.mongosh加载操作系统证书颁发机构已经可用的TLS证书,而无需向shell明确指定证书。您无法关闭此行为。--tlsUseSystemCAcan still be set for backward compatibility, but it has no effect.仍然可以设置为向后兼容性,但它没有效果。Note
This flag applies to both MongoDB connections and OIDC identity provider connections.此标志适用于MongoDB连接和OIDC身份提供程序连接。
Authentication Options身份验证选项
--authenticationDatabase <dbname>Specifies the authentication database where the specified指定创建指定--usernamehas been created. See Authentication Database.--username的身份验证数据库。请参阅身份验证数据库。If you do not specify a value for如果不为--authenticationDatabase, the MongoDB Shell uses the database specified in the connection string.--authenticationDatabase指定值,MongoDB Shell将使用连接字符串中指定的数据库。
--authenticationMechanism <name>Specifies the authentication mechanism the MongoDB Shell uses to authenticate to the指定MongoDB Shell用于向mongodormongos.mongod或mongos进行身份验证的身份验证机制。If you don't specify an如果你不指定authenticationMechanismbut provide user credentials, the MongoDB Shell and drivers attempt to use SCRAM-SHA-256. If this fails, they fall back to SCRAM-SHA-1.authenticationMechanism(身份验证机制),但提供用户凭据,MongoDB Shell和驱动程序会尝试使用SCRAM-SHA-256。如果失败,它们将退回到SCRAM-SHA-1。Value值Description描述SCRAM-SHA-1 RFC 5802 standard Salted Challenge Response Authentication Mechanism using the SHA-1 hash function.使用SHA-1哈希函数的标准Salted Challenge Response认证机制。SCRAM-SHA-256 RFC 7677
standard Salted Challenge Response Authentication Mechanism using the SHA-256 hash function.使用SHA-256哈希函数的标准Salted Challenge Response认证机制。Requires featureCompatibilityVersion set to
4.0.MONGODB-X509 MongoDB TLS / SSL certificate authentication.证书认证。GSSAPI (Kerberos) External authentication using Kerberos. This mechanism is available only in MongoDB Enterprise.使用Kerberos的外部身份验证。此机制仅在MongoDB Enterprise中可用。PLAIN (LDAP SASL) External authentication using LDAP. You can also use使用LDAP进行外部身份验证。您还可以使用PLAINfor authenticating in-database users.PLAIN对数据库中的用户进行身份验证。PLAINtransmits passwords in plain text. This mechanism is available in MongoDB Enterprise and MongoDB Atlas.PLAIN以纯文本形式传输密码。此机制在MongoDB企业版和MongoDB Atlas中可用。MONGODB-OIDC (OpenID Connect) External authentication using OpenID Connect. This mechanism is available in MongoDB Enterprise and MongoDB Atlas.使用OpenID Connect进行外部身份验证。此机制在MongoDB企业版和MongoDB Atlas中可用。MONGODB-AWS(AWS IAM)External authentication using Amazon Web Services Identity and Access Management (AWS IAM) credentials. This mechanism is available in MongoDB Enterprise and MongoDB Atlas.使用Amazon Web Services身份和访问管理(AWS IAM)凭据进行外部身份验证。此机制在MongoDB企业版和MongoDB Atlas中可用。
--gssapiServiceNameSpecify the name of the service using GSSAPI/Kerberos. Only required if the service does not use the default name of使用GSSAPI/Kerberos指定服务的名称。仅当服务不使用默认名称mongodb时才需要。mongodb.This option is available only in MongoDB Enterprise.此选项仅在MongoDB Enterprise中可用。
--sspiHostnameCanonicalization <string>Specifies whether or not to use Hostname Canonicalization.指定是否使用主机名规范化。--sspiHostnameCanonicalizationhas the same effect as setting the与在连接字符串的CANONICALIZE_HOST_NAME:true|falsekey-pair in theauthMechanismPropertiesportion of the connection string.authMechanismProperties部分设置CANONICALIZE_HOST_NAME:true|false键对具有相同的效果。If如果--sspiHostnameCanonicalizationis set to:--sspiHostnameCanonicalization设置为:forwardAndReverse, performs a forward DNS lookup and then a reverse lookup. New in,执行正向DNS查找,然后执行反向查找。mongosh1.3.0.mongosh1.3.0版新增。forward, the effect is the same as setting,效果与设置authMechanismProperties=CANONICALIZE_HOST_NAME:true.authMechanismProperties=CANONICALIZE_HOST_NAME:true相同。none, the effect is the same as setting,效果与设置authMechanismProperties=CANONICALIZE_HOST_NAME:false.authMechanismProperties=CANONICALIZE_HOST_NAME:false相同。
--oidcFlowsSpecifies OpenID Connect flows in a comma-separated list. The OpenID Connect flows specify how以逗号分隔的列表指定OpenID连接流。OpenID连接流指定mongoshinteracts with the identity provider for the authentication process.mongosh如何与身份提供者交互以进行身份验证过程。mongoshsupports the following OpenID Connect flows:支持以下OpenID连接流:OpenID Connect Flow连接流量Description描述auth-codeDefault.违约。mongoshopens a browser and redirects you to the identity provider log-in screen.mongosh打开浏览器,将您重定向到身份提供者登录屏幕。device-authmongoshprovides you with a URL and code to finish authentication. This is considered a less secure OpenID Connect flow but can be used whenmongoshis run in an environment in which it cannot open a browser.mongosh为您提供了一个URL和代码来完成身份验证。这被认为是一个不太安全的OpenID连接流,但可以在mongosh无法打开浏览器的环境中运行时使用。To set要将device-authas a fallback option toauth-code, see the following example:device-auth(设备身份验证)设置为auth-code(身份验证代码)的回退选项,请参阅以下示例:mongosh 'mongodb://localhost/' --authenticationMechanism MONGODB-OIDC --oidcFlows=auth-code,device-auth
--oidcDumpTokensSpecifies whether指定mongoshprints tokens with extra debugging information. Use this option for debugging purposes only.mongosh是否打印带有额外调试信息的令牌。此选项仅用于调试目的。The--oidcDumpTokensoption accepts the following values:--oidcDumpTokens选项接受以下值:Value值Description描述redactedDefault when you only set仅设置--oidcDumpTokens. Prints token debugging information with sensitive data redacted.--oidcDumpTokens时的默认值。打印带有已编辑敏感数据的令牌调试信息。include-secretsPrints token debugging information including credentials that can potentially authenticate to database servers.打印令牌调试信息,包括可能向数据库服务器进行身份验证的凭据。Important
Theinclude-secretsvalue exposes credentials that attackers can use for authentication. Only use this option when unauthorized people cannot view the output ofmongoshand the credentials are necessary for diagnostic purposes.include-secrets值暴露了攻击者可用于身份验证的凭据。仅当未经授权的人员无法查看mongosh的输出,并且出于诊断目的需要凭据时,才使用此选项。
--oidcIdTokenAsAccessTokenSpecifies whether指定mongoshuses the ID token received from the identity provider instead of the access token. Use this option with identity providers that you can't configure to provide JWT access tokens.mongosh是否使用从身份提供程序收到的ID令牌而不是访问令牌。对于无法配置为提供JWT访问令牌的身份提供程序,请使用此选项。
--oidcNoNonceBy default,默认情况下,mongoshsends a nonce parameter during the OIDC Authorization Code Flow.mongosh在OIDC授权代码流期间发送nonce参数。If you set the如果设置了--oidcNoNonceoption,mongoshdoes not send a nonce parameter. Use this option if your identity provider does not support nonce values as part of authorization.--oidcNoNonce选项,mongosh不会发送nonce参数。如果身份提供者不支持随机数值作为授权的一部分,请使用此选项。
--oidcRedirectUriSpecifies a URI where the identity provider redirects you after authentication. The URI must match the configuration of the identity provider. The default is指定身份验证后身份提供程序重定向URI。URI必须与身份提供程序的配置匹配。默认值为http://localhost:27097/redirect.http://localhost:27097/redirect。
--oidcTrustedEndpointIndicates that the current connection is to a trusted endpoint that is not Atlas or表示当前连接到的受信任端点不是Atlas或localhost. This ensures that access tokens are sent to the server.localhost。这确保了访问令牌被发送到服务器。Only use this option when connecting to servers that you trust.仅在连接到您信任的服务器时使用此选项。
--browserSpecifies the browser指定启用mongoshredirects you to whenMONGODB-OIDCis enabled.MONGODB-OIDC时浏览器mongosh将您重定向到的位置。This option is run with the system shell.此选项与系统shell一起运行。Set设置--no-browserto disable opening browsers entirely.--no-browser以完全禁用打开浏览器。
--password <password>, -p <password>Specifies a password with which to authenticate to a MongoDB database that uses authentication. Use in conjunction with the指定用于向使用身份验证的MongoDB数据库进行身份验证的密码。与--usernameand--authenticationDatabaseoptions.--username和--authenticationDatabase选项结合使用。To force the MongoDB Shell to prompt for a password, enter the要强制MongoDB Shell提示输入密码,请输入--passwordoption as the last option and leave out the argument.--password选项作为最后一个选项,并省略参数。
--username <username>, -u <username>Specifies a username with which to authenticate to a MongoDB database that uses authentication. Use in conjunction with the指定用于向使用身份验证的MongoDB数据库进行身份验证的用户名。与--passwordand--authenticationDatabaseoptions.--password和--authenticationDatabase选项结合使用。
Session Options会话选项
--retryWritesEnables Retryable Writes.启用可重试写入。By default, retryable writes are:默认情况下,可重试的写入操作包括:enabled in在mongoshmongosh中启用disabled in the legacy在遗留的mongoshellmongoshell中禁用
To disable retryable writes, use要禁用可重试写入,请使用--retryWrites=false.--retryWrites=false。For more information on sessions, see Client Sessions and Causal Consistency Guarantees.有关会话的更多信息,请参阅客户端会话和因果一致性保证。
Field Level Encryption Options字段级加密选项
--cryptSharedLibPath <string>New in version 8.2.在版本8.2中新增。The path to the Automatic Encryption Shared Library. The library must be version 8.2.0 or higher. Required to use automatic encryption for the自动加密共享库的路径。库必须是8.2.0或更高版本。需要对mongoshshell session.mongoshshell会话使用自动加密。
--awsAccessKeyId <string>An AWS Access Key associated with an IAM user who has与具有AWS键管理服务(KMS)ListandReadpermissions for the AWS Key Management Service (KMS).List和Read权限的IAM用户关联的AWS访问键。mongoshuses the specified--awsAccessKeyIdto access the KMS.mongosh使用指定的--awsAccessKeyId访问KMS。--awsAccessKeyIdis required to enable Client-Side Field Level Encryption for themongoshshell session.--awsAccessKeyIdrequires both of the following command line options:--awsAccessKeyId是为mongoshshell会话启用客户端字段级加密所必需的。--awsAccessKeyId需要以下两个命令行选项:If如果省略--awsAccessKeyIdis omitted, use theMongo()constructor within the shell session to enable client-side field level encryption.--awsAccessKeyId,请在shell会话中使用Mongo()构造函数来启用客户端字段级加密。To mitigate the risk of leaking access keys into logs, consider specifying an environmental variable to为了降低将访问键泄漏到日志中的风险,请考虑将环境变量指定为--awsAccessKeyId.--awsAccessKeyId。
--awsSecretAccessKey <string>An AWS Secret Key associated to the specifiedAWS Secret Key关联到指定的--awsAccessKeyId.--awsAccessKeyId。--awsSecretAccessKeyis required to enable Client-Side Field Level Encryption for themongoshsession.--awsSecretAccessKeyrequires both of the following command line options:--awsSecretAccessKey是为mongosh会话启用客户端字段级加密所必需的。--awsSecretAccessKey需要以下两个命令行选项:If如果省略了--awsSecretAccessKeyand its supporting options are omitted, useMongo()within the shell session to enable client-side field level encryption.--awsSecretAccessKey及其支持选项,请在shell会话中使用Mongo()启用客户端字段级加密。To mitigate the risk of leaking access keys into logs, consider specifying an environmental variable to为了降低访问键泄露到日志中的风险,可以考虑为--awsSecretAccessKey.--awsSecretAccessKey指定一个环境变量。
--awsSessionToken <string>An AWS Session Token associated to the specified与指定的--awsAccessKeyId.--awsAccessKeyId关联的AWS会话令牌。--awsSessionTokenis required to enable Client-Side Field Level Encryption for themongoshshell session.--awsSessionToken是为mongoshshell会话启用客户端字段级加密所必需的。--awsSessionTokenrequires all of the following command line options:需要以下所有命令行选项:If如果省略了--awsSessionTokenand its supporting options are omitted, useMongo()within the shell session to enable client-side field level encryption.--awsSessionToken及其支持选项,请在shell会话中使用Mongo()启用客户端字段级加密。To mitigate the risk of leaking access keys into logs, consider specifying an environmental variable to为了降低访问键泄露到日志中的风险,可以考虑为--awsSessionToken.--awsSessionToken指定一个环境变量。
--keyVaultNamespace <string>The full namespace (用作客户端字段级加密键库的集合的完整命名空间(<database>.<collection>) of the collection used as a key vault for Client-Side Field Level Encryption.<database>.<collection>)。--keyVaultNamespaceis required for enabling client-side field level encryption for themongoshshell session.--keyVaultNamespace是为mongoshshell会话启用客户端字段级加密所必需的。如果指定的命名空间不存在,mongoshcreates the specified namespace if it does not exist.mongosh会创建它。--keyVaultNamespacerequires both of the following command line options:--keyVaultNamespace需要以下两个命令行选项:If如果省略了--keyVaultNamespaceand its supporting options are omitted, use theMongo()constructor within the shell session to enable client-side field level encryption.--keyVaultNamespace及其支持选项,请在shell会话中使用Mongo()构造函数来启用客户端字段级加密。