Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is mongoimport installed on Mac OS X

I'm trying to setup a cronjob for a regularly scheduled import of json data into a mongo database. To conduct the import, I have the following command in the Python script that the cronjob runs:

os.system("mongoimport --jsonArray --db %s --collection %s --file .../data.txt" %(db_name,collection_name))

However, the log file of the cronjob keeps displaying the following error:

sh: mongoimport: command not found

I think I need to call mongoimport with the full file path in the code, but I'm not sure where mongodb/mongod/mongoimport is installed on my system. whereis mongoimport, whereis mongodb, whereis mongod all return nothing.

I installed mongodb with Homebrew. Packages installed with Homebrew are located in /Library/Caches/Homebrew. However, in my system that folder only has a mongodb-2.6.4_1 tar file. Do I have to unpack this tar file to access mongoimport?

Thanks for your help.

like image 954
kernelmachine Avatar asked Sep 15 '14 14:09

kernelmachine


People also ask

Where is Mongodb installed on Mac?

The databases are stored in the /usr/local/var/mongodb/ directory. The mongod. conf file is here: /usr/local/etc/mongod.

Where can I run Mongoimport?

mongoimport is located in the bin directory (eg, /mongodb/bin or wherever you installed it). To import data, open a new Terminal/Command Prompt window and enter mongoimport followed by parameters such as database name, collection name, source file name, etc.

How do you check Mongodb is installed or not in Mac?

“how to check if mongodb is installed” Code Answer'sOpen the command prompt and type "cd c:\program files\mongodb\server\your version\bin". After you enter the bin folder type "mongo start". If you get either a successful connection or failed one it means it's installed at least.


2 Answers

As of June 2020, I installed mongodb latest version using brew as per the documentation , and I faced the same issue command not found: mongoimport .

I had to to install mongodb-database-tools

brew install mongodb/brew/mongodb-database-tools

Then I could use mongoimport

Just adding this solution, incase it helps someone

like image 172
Sanket9394 Avatar answered Oct 14 '22 06:10

Sanket9394


Got the same issue, but I installed mongodb via Mac Port. Unfortunately, from version 3 of mongodb, these mongodb tools are maintained as a separate project, so I updated Mac port to latest version then installed mongo tools separately.

sudo port install mongo-tools

Hope this helps someone that installing mongodb by mac port.

like image 23
Lam Do Avatar answered Oct 14 '22 08:10

Lam Do