'mongoimport command doesn't work

I am trying to use command mongoimport. my mongoshell doesn't autocomplete ( when i use tab key) when i use mongoim. Where it puts me on doubt does mongoimport is not available ?

snippet:

C:\data\db>mongo MongoDB shell version v3.4.4 connecting to: mongodb://127.0.0.1:27017 MongoDB server version: 3.4.4 Server has startup warnings: 2017-09-16T18:55:26.051-0400 I CONTROL [initandlisten] 2017-09-16T18:55:26.051-0400 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database. 2017-09-16T18:55:26.051-0400 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted. 2017-09-16T18:55:26.051-0400 I CONTROL [initandlisten]

MongoDB Enterprise > mongo Mongo( MongoBridge( MongoRunner( MongoDB Enterprise > mongoimp

I found relevant question here in stackoverflow, quit from 'MongoDB Enterprise' can solve this, when i use this command exit(), this makes complete exit from shell.

On server starts, it gives me warning message 'Access control is not enabled for the database' is this could be the problem ?

Help is appreciated



Solution 1:[1]

mongoimport works from the command prompt, not from Mongo Shell. So go back to your system command prompt and fire it there. For example:

C:\>mongoimport --db students --collection scores --file scores.json

Here MongoDB imports data from scores.json file into scores collection in students database of your running MongoDB instance. So you have to ensure following 3 things to make your mongoimport work.

  1. You are inside System command prompt, not inside Mongo Shell.
  2. Your Mongo instance is running.
  3. Your Mongo server bin directory is in PATH environment variable.

Solution 2:[2]

If the json file is a json array, make sure you add the jsonArray at the end of your command. Using RLD example, you would write it like:
C:\>mongoimport --db students --collection scores --file scores.json --jsonArray

Solution 3:[3]

There is nothing wrong with the default MongoDB installation. We are supposed to install MongoDB database tools.

  1. Download MongoDB Database Tools(.zip) from the official website by choosing the correct option
  2. Extract them to "C:\Program Files\MongoDB\Server\5.0\bin"
  3. You are done.

These 2 websites will be helpful:

https://www.youtube.com/watch?v=v2hsB_e0mFA&ab_channel=SriwWorldofCoding

https://www.mongodb.com/try/download/database-tools?tck-docs_databasetools

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 RLD
Solution 2 Jensen
Solution 3 Yash Gandhi