MongoDB启动失败

129 阅读1分钟

Mac重启后,MongoDB经常性的启动失败,常见的两个报错信息

一、command not found: mongod

1、打开终端 输入命令echo $PATH,我们就可以看到配置的有哪些环境变量,这里仅能查看并不能修改,如果没有mongod的,再添加一次

echo $PATH

2、输入命令sudo vi ~/.bash_profile 添加环境变量,如你安装目录下的bin: /usr/local/mongodb/bin

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

3、i 进入编辑 -> Esc 退出编辑 -> :wq 保存退出,然后刷新:source ~/.bash_profile

source ~/.bash_profile

二、about to fork child process, waiting until server is ready for connections. forked process:XX

启动异常报错的大概内容是:

about to fork child process, waiting until server is ready for connections.
forked process: 25468
ERROR: child process failed, exited with error number 1
To see additional information in this output, start without the "--fork" option.

mongodb非正常关闭后,再次启动会产生about to fork child process, waiting until server is ready for connection此异常。 解决方案:

删除mongodb 的data目录下的mongod.lock文件,重启mongodb即可。该文件会生成在日志文件下(跟bin目录同级)

重启加sudo