[英]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 路径。
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.