简体   繁体   English

使用 zsh 在 Mac 上找不到 Mongo 命令?

[英]Mongo command not found on Mac using zsh?

I installed Mongo Db via the official site.我通过官方网站安装了 Mongo Db。 I also created the below folder我还创建了以下文件夹

~/data/db

I added the mongo files in the location as follows:我在如下位置添加了 mongo 文件:

/usr/local/mongodb

Im using zsh so setting the environment variables as suggested in the bash_profile doesnt work for me.我正在使用 zsh,因此按照 bash_profile 中的建议设置环境变量对我不起作用。 My.zshrc file looks as follows my.zshrc 文件如下所示

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

I also ran the source command as follows:我还按如下方式运行了 source 命令:

source ~/.zshrc

However even after trying variations of various answers, I still get:然而,即使在尝试了各种答案的变体之后,我仍然得到:

zsh: command not found: mongo

What am I missing here?我在这里错过了什么?

I have the same problem when I try to install Mongo with official doc 我尝试使用官方文档安装Mongo时遇到相同的问题

This instruction help me to run MongoDB on MacOS Mojave 10.14.6 说明帮助我在MacOS Mojave 10.14.6上运行MongoDB

  1. Try mongod --version 试试mongod --version
  2. If there is no Mongodb installed try enter brew install mongodb 如果没有安装Mongodb,请尝试输入brew install mongodb
  3. After this check installation again with mongod --version 在此之后,再次使用mongod --version检查安装
  4. Then use brew services start mongodb to run MongoDB on startup 然后使用brew services start mongodb以在启动时运行MongoDB

Try brew install mongodb-community-shell .尝试brew install mongodb-community-shell

My case:我的情况:

I did try brew services start mongodb to solve it, but face this issue:我确实尝试了brew services start mongodb来解决它,但是遇到了这个问题:

Error: No available formula with the name "mongodb". Did you mean mongosh or monetdb?

Here is a recommendation on how to solve it where brew install mongodb-community-shell mentioed as part install of the latest Mongo shell: https://developpaper.com/fix-mac-brew-installation-mongodb-error-no-available-formula-with-the-name-mongodb/这是关于如何解决它的建议,其中brew install mongodb-community-shell作为最新 Mongo shell 的一部分安装提到: https://developpaper.com/fix-mac-brew-installation-mongodb-error-no-available -公式-with-the-name-mongodb/

this one worked for me.in new macbook or air we cant find .zhrc or bash这个对我有用。在新的 macbook 或 air 中我们找不到.zhrcbash

in new mac its .zprofile .在新的 mac 中它的.zprofile so change the path in .zprofile所以更改.zprofile中的路径

export PATH=/opt/homebrew/bin:$PATH

      brew install mongodb-community-shell

you can try it it work for me because when downloading mongodb it lacks the shell so when typing mongo in terminal it won't work你可以尝试它对我有用,因为在下载 mongodb 时它缺少 shell 所以在终端中输入 mongo 时它不起作用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM