mongoimport

Import data from a JSON, CSV, or TSV file into a MongoDB instance

Options

NameDescription
--helpReturns information on the options and use of mongoimport
--verbose, -vIncreases the amount of internal reporting returned on standard output or in log files
--quietRuns mongoimport in a quiet mode that attempts to limit the amount of output
--versionReturns the mongoimport release number
--config <filename>Specifies the full path to a YAML configuration file containing sensitive values for the following options to mongoimport
--uri <connectionString>Specifies the resolvable URI connection string of the MongoDB deployment
--host, -h <hostname:port>Specifies the resolvable hostname of the MongoDB deployment
--port <port>Specifies the TCP port on which the MongoDB instance listens for client connections
--sslEnables connection to a mongod or mongos that has TLS/SSL support enabled
--sslCAFile <filename>Specifies the .pem file that contains the root certificate chain from the Certificate Authority
--sslPEMKeyFile <filename>Specifies the .pem file that contains both the TLS/SSL certificate and key
--sslPEMKeyPassword <value>Specifies the password to de-crypt the certificate-key file (i.e. --sslPEMKeyFile)
--sslCRLFile <filename>Specifies the .pem file that contains the Certificate Revocation List
--sslAllowInvalidCertificatesBypasses the validation checks for server certificates and allows the use of invalid certificates
--sslAllowInvalidHostnamesDisables the validation of the hostnames in TLS/SSL certificates
--username, -u <username>Specifies a username with which to authenticate to a MongoDB database that uses authentication
--password, -p <password>Specifies a password with which to authenticate to a MongoDB database that uses authentication
--awsSessionToken <AWS Session Token>Specifies the session token for MONGODB-AWS authentication mechanism
--authenticationDatabase <dbname>Specifies the authentication database where the specified --username has been created
--authenticationMechanism <name>Specifies the authentication mechanism the mongoimport instance uses to authenticate to the mongod or mongos
--gssapiServiceName <serviceName>Specify the name of the service using GSSAPI/Kerberos. This option is available only in MongoDB Enterprise
--gssapiHostName <hostname>Specify the hostname of the service using GSSAPI/Kerberos. This option is available only in MongoDB Enterprise
--db, -d <database>Specifies the name of the database on which to run the mongoimport
--collection, -c <collection>Specifies the name of the collection to import
--fields, -f <field1,field2,...>Specify a comma separated list of field names when importing CSV or TSV files that do not have field names in the first (i.e. header) line of the file
--fieldFile <filename>Specify a file containing a comma separated list of field names when importing CSV or TSV files that do not have field names in the first (i.e. header) line of the file
--ignoreBlanksIgnores empty fields in CSV and TSV exports
--type <type>Specifies the file type to import
--file <filename>Specifies the location and name of a file containing the data to import
--dropModifies the import process so that the target instance drops the collection before importing the data from the input
--headerlineTreats the first line of the input file as a header line
--useArrayIndexFieldsInterpret natural numbers in fields as array indexes when importing CSV or TSV files
--mode <mode>Specifies how the import process should handle existing documents in the database that match documents in the import file
--upsertFields <field1,field2,...>Specifies a list of fields for the query portion of the import process
--stopOnErrorForces mongoimport to halt the insert operation at the first error rather than continuing the operation despite errors
jsonArrayAccepts the import of data expressed with multiple MongoDB documents within a single JSON array
--legacyIndicates that the import data is in Extended JSON v1 format
--maintainInsertionOrderMaintains the order of documents in the import file when inserting documents into the database
--numInsertionWorkers <number>Specifies the number of insertion workers to run concurrently
--writeConcern <document>Specifies the write concern for each write operation that mongoimport performs
--bypassDocumentValidationEnables mongoimport to bypass document validation during the operation
--columnsHaveTypesInstructs mongoimport that the field list specified in --fields, --fieldFile, or --headerline specifies the types of each field
--parseGrace <grace>Specifies how mongoimport handles type coercion failures when importing CSV or TSV files with --columnsHaveTypes