Where is Mongoimport installed on Mac OS X

I am trying to set up a cronjob to import json data into a mongo database regularly. To do the import, I have the following command in a Python script that a cronjob starts:

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

      

However, the cronjob log file keeps showing the following error:

sh: mongoimport: command not found

      

I think I need to call mongoimport with a full file path in 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 have installed mongodb with Homebrew. The packages installed with Homebrew are located in / Library / Caches / Homebrew. However, on my system, there is only a tar file mongodb-2.6.4_1 in this folder. Do I have to unpack this tar file to access mongoimport?

Thank you for your help.

+3


source to share


4 answers


If you have installed MongoDB correctly, you need to create ~/.bash_profile

and assign /usr/local/mongodb/bin

to$PATH environment variable



After that you should be able to access the mongoimport command

+2


source


You have the same problem but I installed mongodb via Mac Port. Unfortunately, since version 3 of mongodb, these mongodb tools are supported as a separate project, so I updated the Mac port to the latest version and then installed the mongo tools separately.

sudo port install mongo-tools



Hope this helps someone who installs mongodb via mac port.

+6


source


If you've used brew to install, it mongod

's in the directory /usr/local/bin/

. Other utilities (mongoimport, mongoexport, etc.) are on the same path. All you have to do is open another terminal.

+1


source


Try using ./mongoimport

orsudo ./mongoimport

After following all these examples, I was able to use it this way from bash

.

-1


source







All Articles