如何在Mac OS X上启动mongodb服务? [英] How to start a mongodb service on mac OS X?

查看:771
本文介绍了如何在Mac OS X上启动mongodb服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Mac上安装了Mongodb,但该进程当前未运行. 如何启动Mongodb服务,以便可以开始使用命令?

I have already installed Mongodb on my mac but the process is currently not running. How do I start the Mongodb service so that I can start using the commands?

推荐答案

在终端中尝试以下步骤:

Try the following steps in Terminal:

which mongod

这将输出到您的mongod的路径,但是如果它不在您的$PATH中,则命令输出将为空.因此,您需要找到可执行文件:

This will output the path to your mongod, but if it is not in your $PATH the command output will be empty. So you need to find your executable:

find / -name 'mongod'

在此命令的输出中,您会看到很多行,其中之一类似于bin/mongod,例如/usr/local/mongodb/bin/mongod.在这种情况下,请采用完整的绝对路径并执行以下操作:

In the output of this command, you will see many lines, one of which will be like bin/mongod, e.g. /usr/local/mongodb/bin/mongod. In that case take the whole absolute path and do the following:

echo "PATH=/usr/local/mongodb/bin/:$PATH" >> ~/.bash_profile
. ~/.bash_profile

然后重试:

mongod --dbpath /your/path

这篇关于如何在Mac OS X上启动mongodb服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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