AI 에이전트의 경우: 문서 인덱스는 https://www.mongodb.com/ko-kr/docs/llms.txt에서 사용할 수 있으며, 모든 페이지의 마크다운 버전은 어떤 URL 경로에 .md를 추가하여 사용할 수 있습니다.
Docs Menu

mongofiles

The mongofiles utility makes it possible to manipulate files stored in your MongoDB instance in GridFS objects from the command line. It is particularly useful as it provides an interface between objects stored in your file system and GridFS.

Run mongofiles from the system command line, not the mongo shell.

mongofiles is now released separately from the MongoDB Server and uses its own versioning, with an initial version of 100.0.0. Previously, mongofiles was released alongside the MongoDB Server and used matching versioning.

참고

이전 문서에 대한 퀵 링크

This documentation is for version 100.19.0 of mongofiles.

mongofiles version 100.19.0 supports the following versions of the MongoDB Server:

  • MongoDB 9.0

  • MongoDB 8.3

  • MongoDB 8.2

  • MongoDB 8.1

  • MongoDB 8.0

  • MongoDB 7.0

  • MongoDB 6.0

  • MongoDB 5.0

  • MongoDB 4.4

  • MongoDB 4.2

While mongofiles may work on earlier versions of MongoDB server, any such compatibility is not guaranteed.

mongofiles version 100.19.0 is supported on the following platforms:

x86_64
ARM64
PPC64LE
s390x

Amazon Linux 2023

Amazon 2

Amazon 2013.03+

Debian 12

Debian 11

Debian 10

Debian 9

RHEL / CentOS 9

RHEL / CentOS 8

RHEL / CentOS 7

RHEL / CentOS 6

SUSE 15

SUSE 12

Ubuntu 24.04

Ubuntu 22.04

Ubuntu 20.04

Ubuntu 18.04

Ubuntu 16.04

Windows 11 이상

Windows Server 2016 이상

macOS 11 이상

macOS 10.12 - 10.15

The mongofiles tool is part of the MongoDB Database Tools package:

➤ Follow the Database Tools Installation Guide to install mongofiles.

The mongofiles command has the following form:

mongofiles <options> <connection-string> <command> <filename or _id>

Run mongofiles from the system command line, not the mongo shell.

The components of the mongofiles command are:

  1. Options. You may use one or more of these options to control the behavior of mongofiles.

  2. Connection String. The connection string of the mongod / mongos to connect to with mongofiles.

  3. Command. Use one of these commands to determine the action of mongofiles.

  4. 로컬 파일 시스템의 파일 이름 또는 GridFS 객체인 식별자입니다.

중요

For replica sets, mongofiles can only read from the set's primary.

In order to connect to a mongod that enforces authorization with the --auth option, you must use the --username and --password options. The connecting user must possess, at a minimum:

  • the read role for the accessed database when using the list, search or get commands,

  • the readWrite role for the accessed database when using the put or delete commands.

mongofiles automatically creates FIPS-compliant connections to a mongod/mongos that is configured to use FIPS mode.

By default, mongofiles uses read preference primary. To override the default, you can specify the read preference in the --readPreference command line option or in the --uri connection string.

If you specify read preference in the URI string and the --readPreference, the --readPreference value overrides the read preference specified in the URI string.

You can specify both the --writeConcern and the --uri connection string option. If write concern is specified using both options, the --writeConcern value overrides the write concern specified in the URI string.

--help

Returns information on the options and use of mongofiles.

--verbose, -v

표준 출력이나 로그 파일에 반환되는 내부 보고의 양이 늘어납니다. 옵션을 여러 번 포함하여 -v 형식의 상세도를 높입니다(예: -vvvvv.)

--quiet

Runs mongofiles in a quiet mode that attempts to limit the amount of output.

이 옵션은 다음과 같은 활동을 억제합니다.

--version

Returns the mongofiles release number.

--config=<filename>

버전 100 의 새로운 기능입니다.3.0.

Specifies the full path to a YAML configuration file that contains sensitive values for the following mongofiles options:

This is the recommended way to specify a password to mongofiles, aside from specifying it through a password prompt. You can use any combination of the arguments in the file.

구성 파일은 다음과 같은 형식을 취합니다:

password: <password>
uri: mongodb://mongodb0.example.com:27017
sslPEMKeyPassword: <password>

If you specify the password option without specifying uri, you can specify the other components of the connection string by using mongofiles command line options, such as --username and --host.

적절한 파일 시스템 권한으로 이 파일을 보호해야 합니다.

중요

--config 옵션을 사용할 때는 다음과 같은 제한 사항 및 동작을 염두에 두세요.

  • password 필드를 제공하고 uri 필드에 충돌하는 비밀번호가 포함된 연결 문자열을 제공하면 mongorestore에서 오류가 발생합니다.

  • If you specify a configuration file with --config and also use the --password, --uri, or --sslPEMKeyPassword mongofiles command line options, the command line option overrides the corresponding configuration file option.

--uri=<connectionString>

따옴표로 묶인 MongoDB 배포의 확인 가능한 URI 연결 문자열을 지정합니다.

--uri="mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]"

Starting with version 100.0 of mongofiles, the connection string may alternatively be provided as a positional parameter, without using the --uri option:

mongofiles mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]

연결 문자열은 mongodb:// 또는 mongodb+srv:// 중 하나로 시작하기만 하면 명령줄의 어느 지점에서나 위치 매개변수로 지정할 수 있습니다. 예시:

mongofiles --username joe --password secret1 mongodb://mongodb0.example.com:27017 --ssl

Only one connection string can be provided. Attempting to include more than one, whether using the --uri option or as a positional argument, will result in an error.

연결 문자열의 구성 요소에 대한 자세한 내용은 연결 문자열 URI 형식 문서를 참조하세요.

참고

connection string의 일부 구성요소는 --username--password와 같은 자체 명시적 명령줄 옵션을 사용하여 지정할 수도 있습니다. 명시적 옵션을 사용하면서 연결 문자열을 제공하고 충돌하는 정보를 지정하면 오류가 발생합니다.

참고

Ubuntu 에서 mongofiles 를 사용하는 18 경우.,04 cannot unmarshal DNS 옵션과 함께 SRV 연결 문자열(mongodb+srv:// 형식)을 사용할 때 --uri 오류 메시지가 표시될 수 있습니다. 이 경우 다음 옵션 중 하나를 대신 사용합니다.

경고

일부 시스템에서는 --uri 옵션으로 연결 문자열에 제공된 비밀번호가 다른 사용자가 호출할 수 있는 ps 와 같은 시스템 상태 프로그램에 표시될 수 있습니다. 대신 다음을 고려하세요.

  • 대화형 암호 프롬프트를 받기 위해 연결 문자열에서 암호를 생략하거나

  • --config 옵션을 사용하여 비밀번호가 포함된 설정 파일을 지정합니다.

--host=<hostname><:port>

Specifies a resolvable hostname for the mongod that holds your GridFS system. By default mongofiles attempts to connect to a MongoDB process running on the localhost port number 27017.

선택적으로 포트 번호를 지정하여 27017이 아닌 다른 포트에서 실행 중인 MongoDB 인스턴스를 연결할 수 있습니다.

또는 URI connection string에 호스트 이름을 직접 지정할 수도 있습니다. --host를 사용하면서 연결 문자열을 제공하고 충돌하는 정보를 지정하면 오류가 발생합니다.

--port=<port>

기본값: 27017

MongoDB 인스턴스가 클라이언트 연결 수신을 대기하는 TCP 포트를 지정합니다.

또는 URI connection string에 직접 포트를 지정할 수도 있습니다. --port 를 사용하면서 연결 문자열 제공하고 충돌하는 정보를 지정하면 오류가 발생합니다.

--ssl

Enables connection to a mongod or mongos that has TLS/SSL support enabled.

또는 URI connection string에서 직접 TLS/SSL 지원을 구성할 수도 있습니다. 연결 문자열을 제공하면서 --ssl을 사용하고 상충하는 정보를 지정하면 오류가 발생합니다.

TLS/SSL 및 MongoDB에 대한 자세한 내용은 TLS/SSL을 위한 mongod 및 mongos 구성클라이언트를 위한 TLS/SSL 구성을 참조하세요.

--sslCAFile=<filename>

인증 기관의 루트 인증서 체인이 포함된 .pem 파일을 지정합니다. 상대 경로 또는 절대 경로를 사용하여 .pem 파일의 이름을 지정합니다.

또는 URI connection string에 직접 .pem 파일을 지정할 수도 있습니다. --sslCAFile를 사용하면서 연결 문자열을 제공하고 충돌하는 정보를 지정하면 오류가 발생합니다.

TLS/SSL 및 MongoDB에 대한 자세한 내용은 TLS/SSL을 위한 mongod 및 mongos 구성클라이언트를 위한 TLS/SSL 구성을 참조하세요.

--sslPEMKeyFile=<filename>

TLS/SSL 인증서와 키가 모두 포함되어 있는 .pem 파일을 지정합니다. 상대 경로 또는 절대 경로를 사용해 .pem 파일의 이름을 지정합니다.

This option is required when using the --ssl option to connect to a mongod or mongos that has CAFile enabled without allowConnectionsWithoutCertificates.

또는 URI connection string에 직접 .pem 파일을 지정할 수도 있습니다. --sslPEMKeyFile를 사용하면서 연결 문자열을 제공하고 충돌하는 정보를 지정하면 오류가 발생합니다.

TLS/SSL 및 MongoDB에 대한 자세한 내용은 TLS/SSL을 위한 mongod 및 mongos 구성클라이언트를 위한 TLS/SSL 구성을 참조하세요.

--sslPEMKeyPassword=<value>

Specifies the password to de-crypt the certificate-key file (i.e. --sslPEMKeyFile). Use the --sslPEMKeyPassword option only if the certificate-key file is encrypted. In all cases, the mongofiles will redact the password from all logging and reporting output.

If the private key in the PEM file is encrypted and you do not specify the --sslPEMKeyPassword option, the mongofiles will prompt for a passphrase. See TLS/SSL Certificate Passphrase.

또는 URI connection string에 비밀번호를 직접 지정할 수도 있습니다. --sslPEMKeyPassword를 사용하면서 연결 문자열을 제공하고 충돌하는 정보를 지정하면 오류가 발생합니다.

TLS/SSL 및 MongoDB에 대한 자세한 내용은 TLS/SSL을 위한 mongod 및 mongos 구성클라이언트를 위한 TLS/SSL 구성을 참조하세요.

경고

일부 시스템에서는 --sslPEMKeyPassword 옵션을 사용해 직접 제공된 비밀번호가 다른 사용자가 호출할 수 있는 ps와 같은 시스템 상태 프로그램에 표시될 수 있습니다. 대신 --config 옵션을 사용하여 비밀번호가 포함된 설정 파일을 지정하는 것이 좋습니다.

--sslCRLFile=<filename>

인증서 해지 목록이 포함된 .pem 파일을 지정합니다. 상대 경로 또는 절대 경로를 .pem 파일의 이름을 지정합니다.

TLS/SSL 및 MongoDB에 대한 자세한 내용은 TLS/SSL을 위한 mongod 및 mongos 구성클라이언트를 위한 TLS/SSL 구성을 참조하세요.

--sslAllowInvalidCertificates

Bypasses the validation checks for server certificates and allows the use of invalid certificates. When using the allowInvalidCertificates setting, MongoDB logs as a warning the use of the invalid certificate.

경고

--sslAllowInvalidCertificates 옵션은 사용할 수 있는 경우에도 가급적 사용하지 않는 것이 좋습니다. --sslAllowInvalidCertificates를 사용해야만 하는 경우, 침입이 불가능한 시스템에서만 옵션을 사용하세요.

Connecting to a mongod or mongos instance without validating server certificates is a potential security risk. If you only need to disable the validation of the hostname in the TLS/SSL certificates, see --sslAllowInvalidHostnames.

또는 URI connection string에서 직접 인증서 유효성 검사 비활성화할 수도 있습니다. --sslAllowInvalidCertificates 를 사용하면서 연결 문자열 제공하고 충돌하는 정보를 지정하면 오류가 발생합니다.

TLS/SSL 및 MongoDB에 대한 자세한 내용은 TLS/SSL을 위한 mongod 및 mongos 구성클라이언트를 위한 TLS/SSL 구성을 참조하세요.

--sslAllowInvalidHostnames

Disables the validation of the hostnames in TLS/SSL certificates. Allows mongofiles to connect to MongoDB instances even if the hostname in their certificates do not match the specified hostname.

또는 URI connection string에서 호스트 이름 유효성 검사를 비활성화할 수도 있습니다. --sslAllowInvalidHostnames를 사용하면서 연결 문자열을 제공하고 충돌하는 정보를 지정하면 오류가 발생합니다.

TLS/SSL 및 MongoDB에 대한 자세한 내용은 TLS/SSL을 위한 mongod 및 mongos 구성클라이언트를 위한 TLS/SSL 구성을 참조하세요.

--username=<username>, -u=<username>

Specifies a username with which to authenticate to a MongoDB database that uses authentication. Use in conjunction with the --password and --authenticationDatabase options.

또는 URI connection string에 직접 사용자 이름을 지정할 수도 있습니다. --username을 사용하면서 연결 문자열을 제공하고 충돌하는 정보를 지정하면 오류가 발생합니다.

If connecting to a MongoDB Atlas cluster using the MONGODB-AWS authentication mechanism, you can specify your AWS access key ID in:

각각의 예는 AWS IAM 자격 증명을 사용하여 MongoDB Atlas 클러스터에 연결하기를 참조하세요.

--password=<password>, -p=<password>

Specifies a password with which to authenticate to a MongoDB database that uses authentication. Use in conjunction with the --username and --authenticationDatabase options.

To prompt the user for the password, pass the --username option without --password or specify an empty string as the --password value, as in --password "" .

또는 URI connection string에 비밀번호를 직접 지정할 수도 있습니다. --password를 사용하면서 연결 문자열을 제공하고 충돌하는 정보를 지정하면 오류가 발생합니다.

If connecting to a MongoDB Atlas cluster using the MONGODB-AWS authentication mechanism, you can specify your AWS secret access key in:

각각의 예는 AWS IAM 자격 증명을 사용하여 MongoDB Atlas 클러스터에 연결하기를 참조하세요.

경고

일부 시스템에서는 --password 옵션을 사용해 직접 제공된 비밀번호가 다른 사용자가 호출할 수 있는 ps와 같은 시스템 상태 프로그램에 표시될 수 있습니다. 대신 다음을 고려해 보세요.

  • --password 옵션을 생략하여 대화형 비밀번호 프롬프트를 받거나

  • --config 옵션을 사용하여 비밀번호가 포함된 설정 파일을 지정합니다.

--awsSessionToken=<AWS Session Token>

If connecting to a MongoDB Atlas cluster using the MONGODB-AWS authentication mechanism, and using session tokens in addition to your AWS access key ID and secret access key, you can specify your AWS session token in:

각각의 예는 AWS IAM 자격 증명을 사용하여 MongoDB Atlas 클러스터에 연결하기를 참조하세요.

MONGODB-AWS authentication mechanism을(를) 사용할 때만 유효합니다.

--authenticationDatabase=<dbname>

Specifies the authentication database where the specified --username has been created. See Authentication Database.

If you use the GSSAPI (Kerberos), PLAIN (LDAP SASL), or MONGODB-AWS authentication mechanisms, you must set --authenticationDatabase to $external.

또는 URI connection string에서 직접 인증 데이터베이스를 지정할 수도 있습니다. --authenticationDatabase를 사용하면서 연결 문자열을 제공하고 충돌하는 정보를 지정하면 오류가 발생합니다.

--authenticationMechanism=<name>

기본값: SCRAM-SHA-1

Specifies the authentication mechanism the mongofiles instance uses to authenticate to the mongod or mongos.

버전 100.1.0에서 변경됨:

Starting in version 100.1.0, mongofiles adds support for the MONGODB-AWS authentication mechanism when connecting to a MongoDB Atlas cluster.

설명

RFC 7677 standard Salted Challenge Response Authentication Mechanism using the SHA-256 hash function.

featureCompatibilityVersion이 4.0으로 설정되어야 합니다.

MongoDB TLS/SSL 인증서 인증.

MONGODB-AWS

MongoDB Atlas 클러스터 연결에 사용하기 위한 AWS IAM 자격 증명을 사용하는 외부 인증입니다. AWS IAM 자격 증명을 사용하여 MongoDB Atlas 클러스터에 연결하기를 참조하세요.

버전 100 의 새로운 기능입니다.1.0.

GSSAPI (Kerberos)

Kerberos를 사용한 외부 인증. 이 메커니즘은 MongoDB Enterprise에서만 사용할 수 있습니다.

PLAIN (LDAP SASL)

LDAP를 사용한 외부 인증. PLAIN 을 사용해 데이터베이스 내 사용자를 인증할 수도 있습니다. PLAIN 은 비밀번호를 일반 텍스트로 전송합니다. 이 메커니즘은 MongoDB Enterprise에서만 사용할 수 있습니다.

또는 URI connection string에서 직접 인증 메커니즘을 지정할 수도 있습니다. --authenticationMechanism를 사용하면서 연결 문자열을 제공하고 충돌하는 정보를 지정하면 오류가 발생합니다.

--gssapiServiceName=<serviceName>

Specify the name of the service using GSSAPI/Kerberos. Only required if the service does not use the default name of mongodb.

이 옵션은 MongoDB Enterprise에서만 사용할 수 있습니다.

--gssapiHostName=<hostname>

GSSAPI/Kerberos를 사용하여 서비스의 호스트 이름을 지정합니다. 시스템의 호스트 이름이 DNS에서 확인한 호스트 이름과 일치하지 않는 경우에만 필요합니다.

이 옵션은 MongoDB Enterprise에서만 사용할 수 있습니다.

--db=<database>, -d=<database>

Specifies the name of the database on which to run the mongofiles.

또는 URI connection string에 직접 데이터베이스를 지정할 수도 있습니다. --db를 사용하면서 연결 문자열을 제공하고 충돌하는 정보를 지정하면 오류가 발생합니다.

--local=<filename>, -l=<filename>

가져오기 및 넣기 작업에 사용할 파일의 로컬 파일 시스템 이름을 지정합니다.

In the mongofiles put and mongofiles get commands, the required <filename> modifier refers to the name the object will have in GridFS. mongofiles assumes that this reflects the file's name on the local file system. This setting overrides this default.

--type=<MIME>

Provides the ability to specify a MIME type to describe the file inserted into GridFS storage. mongofiles omits this option in the default operation.

mongofiles put 작업에만 사용합니다.

--replace, -r

동일한 이름의 객체를 추가하는 대신 기존 GridFS 객체를 지정된 로컬 파일로 대체하기 위해 mongofiles put의 동작을 변경합니다.

기본 작업에서는 mongofiles put 옵션으로 파일을 덮어쓰지 않습니다.

--prefix=<string>

기본값: fs

사용할 GridFS 접두사입니다.

--writeConcern=<document>

기본값: 대다수(majority)

Specifies the write concern for each write operation that mongofiles performs.

w 옵션을 사용하여 쓰기 고려를 문서로 지정합니다.

--writeConcern="{w:'majority'}"

If the write concern is also included in the --uri connection string, the command-line --writeConcern overrides the write concern specified in the URI string.

--readPreference=<string|document>

Default: primary

Specifies the read preference for mongofiles. The --readPreference option can take:

  • 읽기 설정 모드만 지정하는 경우 문자열입니다:

    --readPreference=secondary
  • 따옴표로 묶인 문서를 통해 모드, 선택적 읽기 설정 태그 세트 및 선택적 maxStalenessSeconds를 지정할 수 있습니다.

    --readPreference='{mode: "secondary", tagSets: [ { "region": "east" } ], maxStalenessSeconds: 120}'

    maxStalenessSeconds를 지정하는 경우 이 값은 보다 크거나 같아야 90 합니다.

mongofiles defaults to primary read preference.

If the read preference is also included in the --uri connection string, the command-line --readPreference overrides the read preference specified in the URI string.

list <prefix>

GridFS 저장소에 있는 파일을 나열합니다. list 뒤에 지정된 문자 (예: <prefix>)의 경우 반환된 항목 목록을 해당 문자열로 시작하는 파일로 선택적으로 제한합니다.

search <string>

<string>의 일부와 일치하는 이름을 가진 GridFS 저장소의 파일을 나열합니다.

put <filename1[ filename2] ...>

지정한 파일을 로컬 파일 시스템에서 GridFS 스토리지로 복사합니다. 여러 파일을 공백으로 구분된 목록으로 지정할 수 있습니다.

Each specified filename refers to the name the object will have in GridFS, and mongofiles assumes that this reflects the name the file has on the local file system. If the local filename is different, use the mongofiles --local option.

get <filename1[ filename2] ...>

지정한 파일을 GridFS 스토리지에서 로컬 파일 시스템으로 복사합니다.

Each specified filename refers to the name the object has in GridFS, and mongofiles will use this filename when writing to the local file system.

If specifying only one filename to the get command, you can use the --local option to specify a different local filename to write to, if desired. The --local option cannot be used if specifying more than one filename to the get command.

참고

GridFS 스토리지에서 정규 표현식과 일치하는 파일을 복사하려면 get_regex 명령을 대신 사용합니다.

get_id "<_id>"

<_id>로 지정된 파일을 GridFS 저장소에서 로컬 파일 시스템으로 복사합니다. <_id>는 GridFS에 있는 객체의 확장 JSON _id를 참조합니다. get_id<_id>에 대해 ObjectId 값 또는 비-ObjectId 값을 허용할 수 있습니다.

mongofiles writes the file to the local file system using the file's filename in GridFS. To choose a different location for the file on the local file system, use the --local option.

get_regex <regex> --regexOptions <regex-options>

지정된 <regex> 표현식과 일치하는 파일을 GridFS 스토리지에서 로컬 파일 시스템으로 복사합니다. get_regex 명령은 UTF-8 지원이 포함된 펄(Perl) 호환 정규 표현식(" PCRE ") 버전 8.42를 사용합니다.

You may optionally specify one or more <regex-options> using the --regexOptions flag. These can be any of the options supported by the $regex operator, which include settings such as case-insensitivity. Multiple options should be provided together without separators, e.g. --regexOptions si

mongofiles writes the file or files to the local file system using each file's matched filename in GridFS. You cannot use the --local option with the get_regex command.

delete <filename>

지정한 파일을 GridFS 스토리지에서 삭제합니다.

delete_id "<_id>"

<_id>(으)로 지정된 파일을 GridFS 저장소에서 삭제합니다. delete_id<_id>에 대해 ObjectId 값 또는 비-ObjectId 값을 받아들일 수 있습니다.

Run mongofiles from the system command line, not the mongo shell.

To return a list of all files in a GridFS collection in the records database, use the following invocation at the system shell:

mongofiles -d=records list

This mongofiles instance will connect to the mongod instance running on the 27017 localhost interface to specify the same operation on a different port or hostname, and issue a command that resembles one of the following:

mongofiles --port=37017 -d=records list
mongofiles --host=db1.example.net -d=records list
mongofiles --host=db1.example.net --port=37017 -d=records list

Modify any of the following commands as needed if you're connecting the mongod instances on different ports or hosts.

32-corinth.lp 파일을 records 데이터베이스의 GridFS 컬렉션에 업로드하려면 다음 명령을 사용할 수 있습니다.

mongofiles -d=records put 32-corinth.lp

records 데이터베이스 내 해당 GridFS 컬렉션에서 32-corinth.lp 파일을 삭제하려면 다음 명령을 사용할 수 있습니다.

mongofiles -d=records delete 32-corinth.lp

records 데이터베이스 내 GridFS 컬렉션의 파일 중 이름에 corinth(이)가 포함된 파일을 검색하려면 다음 명령을 사용할 수 있습니다:

mongofiles -d=records search corinth

records 데이터베이스의 GridFS 컬렉션에서 이름이 32 문자열로 시작하는 모든 파일을 나열하려면 다음 명령을 사용할 수 있습니다:

mongofiles -d=records list 32

records 데이터베이스의 GridFS 컬렉션에서 32-corinth.lp이라는 파일을 불러오려면 다음 명령을 사용할 수 있습니다.

mongofiles -d=records get 32-corinth.lp

records 데이터베이스의 GridFS 컬렉션에서 이름이 32 문자열로 시작하고 .lp 문자열로 끝나는 모든 파일을 불러오려면 다음 명령을 사용할 수 있습니다:

mongofiles -d=records get_regex 32*.lp

records 데이터베이스의 GridFS 컬렉션에서 _id: ObjectId("56feac751f417d0357e7140f")인 파일을 불러오려면 다음 명령을 사용할 수 있습니다:

mongofiles -d=records get_id '{"$oid": "56feac751f417d0357e7140f"}'

_id 주위에 따옴표를 넣어야 합니다.

버전 100 의 새로운 기능입니다.1.0.

To connect to a MongoDB Atlas cluster which has been configured to support authentication via AWS IAM credentials, provide a connection string to mongofiles similar to the following:

mongofiles 'mongodb+srv://<aws access key id>:<aws secret access key>@cluster0.example.com/testdb?authSource=$external&authMechanism=MONGODB-AWS' <other options>

Connecting to Atlas using AWS IAM credentials in this manner uses the MONGODB-AWS authentication mechanism and the $external authSource, as shown in this example.

If using an AWS session token, as well, provide it with the AWS_SESSION_TOKEN authMechanismProperties value, as follows:

mongofiles 'mongodb+srv://<aws access key id>:<aws secret access key>@cluster0.example.com/testdb?authSource=$external&authMechanism=MONGODB-AWS&authMechanismProperties=AWS_SESSION_TOKEN:<aws session token>' <other options>

참고

AWS 액세스 키 ID, 보안 액세스 키 또는 세션 토큰에 다음 문자가 포함되어 있는 경우

: / ? # [ ] @

이 문자들은 퍼센트 인코딩을 사용하여 변환해야 합니다.

Alternatively, the AWS access key ID, secret access key, and optionally session token can each be provided outside of the connection string using the --username, --password, and --awsSessionToken options instead, like so:

mongofiles 'mongodb+srv://cluster0.example.com/testdb?authSource=$external&authMechanism=MONGODB-AWS' --username <aws access key id> --password <aws secret access key> --awsSessionToken <aws session token> <other options>

명령줄 매개변수로 제공되는 경우 이러한 세 가지 옵션에는 퍼센트 인코딩이 필요하지 않습니다.

You may also set these credentials on your platform using standard AWS IAM environment variables. mongofiles checks for the following environment variables when you use the MONGODB-AWS authentication mechanism:

  • AWS_ACCESS_KEY_ID

  • AWS_SECRET_ACCESS_KEY

  • AWS_SESSION_TOKEN

설정된 경우 이러한 자격 증명은 연결 문자열이나 명시적 옵션을 통해 지정할 필요가 없습니다.

참고

AWS 환경 변수를 사용하여 이러한 값을 지정하기로 선택한 경우 이러한 자격 증명에 해당하는 명시적 또는 연결 문자열 옵션과 조합하여 사용할 수 없습니다. 액세스 키 ID 비밀 액세스 키(사용 중인 경우 세션 토큰도 함께 필요)에 환경 변수를 사용하거나 또는 명시적 또는 연결 문자열 옵션을 사용하여 각각을 지정합니다.

다음 예시에서는 bash 셸에서 이러한 환경 변수를 설정합니다.

export AWS_ACCESS_KEY_ID='<aws access key id>'
export AWS_SECRET_ACCESS_KEY='<aws secret access key>'
export AWS_SESSION_TOKEN='<aws session token>'

다른 셸에서 환경 변수를 설정하는 구문은 다를 수 있습니다. 자세한 내용은 사용 중인 플랫폼의 설명서를 참조하세요.

다음 명령어로 이러한 환경 변수가 설정되었는지 확인할 수 있습니다.

env | grep AWS

설정이 완료되면 다음 예시에서는 이러한 환경 변수를 사용하여 MongoDB Atlas 클러스터에 연결합니다.

mongofiles 'mongodb+srv://cluster0.example.com/testdb?authSource=$external&authMechanism=MONGODB-AWS' <other options>