mac:找不到命令:mongod [英] mac: command not found: mongod

查看:114
本文介绍了mac:找不到命令:mongod的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在MacOS上通过brew安装了mongodb作为mongodb的官方文档,但是我尝试手动运行MongoDB作为后台进程,使用命令"mongod --config/usr/local/etc/mongod.conf --fork".然后,终端显示的消息是:找不到命令:mongo.

I installed mongodb by brew on my MacOS as the mongodb official documentation, but I tried to run MongoDB manually as a background process, use command "mongod --config /usr/local/etc/mongod.conf --fork". Then the terminal displayed the message is : command not found: mongo.

我错过任何步骤了吗?

推荐答案

PATH 环境变量中未包含 mongodb 可执行文件时,会出现上述错误.

The above error appears when mongodb executable is not included in the PATH environment variable.

MongoDB已安装到/usr/local/bin/mongod

MongoDB gets installed to /usr/local/bin/mongod

'mongod --config/usr/local....' 命令只有在 '/usr/local/bin' 包含在 PATH 中时才有效.

The command 'mongod --config /usr/local....' will work only if '/usr/local/bin' is included in PATH.

如何解决该问题?

问题可以通过2种方法解决-

The problem can be fixed in 2 ways -

  1. 以完整路径调用mongod命令

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

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

  1. 将'/usr/local/bin'添加到PATH

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

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

运行上述命令,或将以上行添加到 .zshrc 文件和 .bash_profile 文件的末尾,并在 mongodb 命令中执行新的终端窗口.

Run the above command or add the above line to the end of .zshrc file and .bash_profile file and execute mongodb command in a new terminal window.

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

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

这篇关于mac:找不到命令:mongod的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆