cant use mongo command, shows command not found on

2019-01-11 07:23发布

问题:

I am using Mac Lion. I was using mongodb version 1.4. i wanted to upgrade to 1.8.5 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 

its ok. I can access localhost:28017 but,

mongo

shows command not found

how i can i fix this

回答1:

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



回答2:

1.Go to your [mongodb installation dir]:

cd <mongodb installation dir>

2.Type ./bin/mongo to start mongo:

./bin/mongo

Read More

Note :

If above command gives error

Failed global initialization: BadValue Invalid or no user locale set. Please ensure LANG and/or LC_ environment variables are set correctly.*

Run bellow command: Read More

export LC_ALL=C

How can find installation directory

find / -name "mongodb" 

You can also set path

export PATH=$PATH:<mongodb installation dir>/bin


回答3:

You can navigate to the mongo directory using the command line and then start MongoDB with

./mongodb

I was facing the same problem this worked for me.



回答4:

documentation

export PATH={mongodb-install-directory}/bin:$PATH


标签: macos mongodb