Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting "'mongoimport' is not recognized as an internal or external command, operable program, or batch file." when trying to import data from a file

New to MongoDB. I'm following this tutorial, and I get the above error when trying to follow Step 2. I'm putting the command into a Windows Command Prompt, and I've set my directory to the location of the 'mongoimport' file (C:\MongoDB). I've also included the same directory in my PATH, and the primer-dataset.json file is saved in that location. I'm fairly confident MongoDB is installed properly.

like image 213
Patrick R Miles Avatar asked Jun 25 '15 16:06

Patrick R Miles


People also ask

How do I import data into Mongoimport?

If you have CSV files (or TSV files - they're conceptually the same) to import, use the --type=csv or --type=tsv option to tell mongoimport what format to expect. Also important is to know whether your CSV file has a header row - where the first line doesn't contain data - instead it contains the name for each column.

How do I import a restaurant JSON file into MongoDB?

To import JSON file you need to follow the following steps: Step 1: Open a command prompt and give command mongod to connect with MongoDB server and don't close this cmd to stay connected to the server. Step 2: Open another command prompt and run the mongo shell. Using the mongo command.


1 Answers

From Version 4.4.0 You have to install the MongoDB Database Tools separately, mentioned here.

To install.Then to go the bin directory of Tools (mostly C:\Program Files\MongoDB\Tools\[version]\bin) and open command prompt there.

Now execute the command here. This should work or else add .\in the beginning as mentioned by Cody w above.

If you want to execute your command from your current path (not only from mostly: C:\Program Files\MongoDB\Tools...\bin Path), you can do step 3 of this link (Make the DB Tools available in your PATH)

like image 138
Uchiha012 Avatar answered Oct 17 '22 09:10

Uchiha012