简体   繁体   English

Zsh: Command Not found: mongo 尝试使用 brew 安装 mongodb 4.2 后

[英]Zsh: Command Not found : mongo After trying to install mongodb 4.2 using brew

I have tried the following steps to install and setup mongodb in my mac from here https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/ but I got the following error when running the final " mongo " command in my terminal:我已经尝试了以下步骤在我的 Mac 中安装和设置 mongodb 从这里https://docs.mongodb.com/manual/tutorial/install我得到以下错误时运行-final-tutorial/我的终端中的“ mongo ”命令:

Error Message - Zsh: Command Not found: mongo错误消息 - Zsh:找不到命令:mongo

This error msg occurred after trying to install mongodb 4.2 using brew尝试使用 brew 安装 mongodb 4.2 后出现此错误消息

sudo chown -R $(whoami) $(brew --prefix)/*

then

brew tap mongodb/brew

then

brew install mongodb-community@4.2

and

brew services start mongodb-community@4.2

or

mongod --config /usr/local/etc/mongod.conf

then

ps aux | grep -v grep | grep mongod

and

mongo

running brew services start mongodb-community@4.2 returns:运行brew services start mongodb-community@4.2返回:

Successfully started `mongodb-community@4.2` (label: homebrew.mxcl.mongodb-community@4.2)

running ps aux |运行ps aux | grep -v grep | grep -v grep | grep mongod returns: grep mongod返回:

9081   0.2  0.5  5528024  41856   ??  S     3:01pm   0:01.48 /usr/local/opt/mongodb-community@4.2/bin/mongod --config /usr/local/etc/mongod.conf

7613   0.0  0.1  4298832   5600 s000  T     2:47pm   0:00.08 vim /usr/local/etc/mongod.conf

running mongod --config /usr/local/etc/mongod.conf returns:运行 mongod --config /usr/local/etc/mongod.conf 返回:

zsh: command not found: mongod

There are also no mongo files in my /usr/local/bin directory after using these commands使用这些命令后,我的 /usr/local/bin 目录中也没有 mongo 文件

I created a data/db folder in my /usr/local/bin directory using the following commands:我使用以下命令在 /usr/local/bin 目录中创建了一个 data/db 文件夹:

sudo mkdir -p  /usr/local/bin/data/db   
sudo chown -R `id -un`  /usr/local/bin/data/db      

Running " brew update " returns:运行“ brew update ”返回:

brew update                                                                                                                                                    
Updated 1 tap (homebrew/cask).
==> Updated Casks
brave-browser

Solved it by manually installing the mongodb community files and db tools using the website instead.通过使用网站手动安装 mongodb 社区文件和数据库工具来解决它。 Then copying them into /usr/local/bin.然后将它们复制到 /usr/local/bin 中。 Then ignoring the app permissions whenever calling mongo or related commands in the terminal through System Preferences > Security & Privacy > General.然后通过 System Preferences > Security & Privacy > General 在终端中调用 mongo 或相关命令时忽略应用程序权限。

After googling I found out that mongoimport and the other features have to be installed separately: https://www.mongodb.com/try/download/database-tools谷歌搜索后,我发现 mongoimport 和其他功能必须单独安装: https://www.mongodb.com/try/download/database-tools

Followed by copying those bin files after extracting them into the same /usr/local/bin directory然后将这些 bin 文件解压缩到相同的 /usr/local/bin 目录中

Not sure why its' not working through homebrew though不知道为什么它不能通过自制软件工作

If you installed the mongodb via Homebrew.如果您通过 Homebrew 安装了 mongodb。 Need to add the mongo path in your bash_profile.需要在 bash_profile 中添加 mongo 路径。

  • Edit the bash_profile vi ~/.bash_profile编辑 bash_profile vi ~/.bash_profile
  • Add the below line in EOF export PATH=$PATH:/usr/local/opt/mongodb-community@4.2/bin在 EOF export PATH=$PATH:/usr/local/opt/mongodb-community@4.2/bin 中添加以下行
  • After the edit bash_profile.编辑 bash_profile 之后。 Close all terminals and open them again.关闭所有终端并再次打开它们。 mongo command start works. mongo 命令启动有效。

This worked for me, I was having same issue on mongodb-community@4.4这对我有用,我在 mongodb-community@4.4 上遇到了同样的问题

 brew reinstall mongodb-community@4.4  

On terminal something like this will appear during reinstallation.在终端上,重新安装过程中会出现类似的情况。

在此处输入图像描述

copy highlighted path with echo使用回声复制突出显示的路径

 echo 'export PATH="/opt/homebrew/opt/mongodb-community@4.4/bin:$PATH"' >> ~/.zshrc

Now open another terminal and start mongodb services现在打开另一个终端并启动 mongodb 服务

brew services restart mongodb/brew/mongodb-community@4.4

write mongo on terminal and here we fly在终端上写 mongo,我们飞到这里

在此处输入图像描述

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

相关问题 使用和运行 brew services start mongodb-community@4.2 出现问题 - Problem using and running brew services start mongodb-community@4.2 下载后如何启动Mongo Db。 命令./mongod不起作用 - How to start Mongo Db after download. Command ./mongod not working Mongodb:为什么我的mongo服务器使用两个PID? - Mongodb: why is my mongo server using two PID's? 什么是 MongoDB 实例? 为什么不能执行 CRUD 操作或访问 Mongo 命令行 shell? - What is MongoDB instances? Why could you possible not perform CRUD operations or access Mongo Command line shell? 我正在尝试在 ubuntu 上安装 mongo db 并解决这个未满足的依赖问题 - I am trying to install mongo db on ubuntu and getiing this issue of unmet dependency 尝试插入 Mongo DB 时,Elixir 项目中的“不支持的 OP_QUERY 命令:插入” - "Unsupported OP_QUERY command: insert" in Elixir project when trying to insert into Mongo DB 使用 db.command 在 mongodb 中的唯一索引 - Unique index in mongodb using db.command 使用命令行 linux 安装 android sdk - install android sdk using command line linux 从 MongoDB 4.2 数据库中删除重复项 - Remove duplicates from MongoDB 4.2 data base Rock Mongo mongodb配置设置 - Rock Mongo mongodb config settings
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM