Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't use mongo command, shows command not found on mac

Tags:

macos

mongodb

I'm using Mac Lion. I was using mongodb version 1.4. I wanted to upgrade to 1.8.5 and I followed http://shiftcommathree.com/articles/how-to-install-mongodb-on-os-x step wise replacing each mongodb-osx-x86_64-1.4.0 by mongodb-osx-x86_64-1.8.5. Everything goes smooth. I tried:

mongod  

it's ok. I can access localhost:28017 but,

mongo 

shows command not found

How can I fix this?

like image 634
Ajay Avatar asked Apr 18 '12 05:04

Ajay


People also ask

Why MongoDB command not found?

To correct this issue, you can delete the file sudo rm /tmp/mongodb-27017. lock and then start the mongod process once more, which will recreate the file.

How do I run a mongo shell on a Mac?

Run the Mongo daemon, in one terminal window run ~/mongodb/bin/mongod . This will start the Mongo server. Run the Mongo shell, with the Mongo daemon running in one terminal, type ~/mongodb/bin/mongo in another terminal window. This will run the Mongo shell which is an application to access data in MongoDB.

How do you run a command in mongo shell?

To open up the MongoDB shell, run the mongo command from your server prompt. By default, the mongo command opens a shell connected to a locally-installed MongoDB instance running on port 27017 . Try running the mongo command with no additional parameters: mongo.


2 Answers

You need to add the path to "mongo" to your terminal shell.

export PATH=$PATH:/usr/local/mongodb/bin 

Did you do the last step with paths.d? If so, try restarting your terminals.

Do you have a good reason for using 1.8.5? The current stable is 2.0.4, and it has many useful upgrades from 1.8.x

like image 167
Eve Freeman Avatar answered Sep 29 '22 13:09

Eve Freeman


For readers in 2021:

export PATH="$PATH:/usr/local/opt/[email protected]/bin" 

enter image description here

like image 41
Rainning Avatar answered Sep 29 '22 11:09

Rainning