这篇文章主要介绍“mac下MongoDB没有启动是什么缘故,怎么办好”,有一些人在mac下MongoDB没有启动是什么缘故,怎么办好的问题上存在疑惑,接下来小编就给大家来介绍一下相关的内容,希望对大家解答有帮助,有这个方面学习需要的朋友就继续往下看吧。
解决方法1
原因:mongodb没有启动
用brew service来启动
brew services start mongodb
解决方法2
原因:没有db文件夹
Before you start MongoDB for the first time, create the directory to which the mongod process will
write data. By default, the mongod process uses the /data/db directory. If you create a directory other
than this one, you must specify that directory in the dbpath option when starting the mongod process
later in this procedure.
1. 创建文件夹
mkdir -p /data/db
2. 给文件夹设置可写
sudo chown -R `id -un` /data/db
3. 运行mongodb
cd /usr/local/mongodb/bin
mongod
mongo
4. 结束运行mongodb
Control+C
解决方法3
原因:因意外造成Mongodb服务非正常关闭且造成Mongod服务无法正常启动
删除data目录下的*.lock文件
sudo rm /data/db/mongod.lock
sudo rm /data/db/WiredTiger.lock
然后再启动Mongod服务
cd /usr/local/mongodb/bin
mongod
mongo
如果还是不行,可以查看一下进程,然后杀掉:
ps -aef | grep mongo
kill ***
cd /usr/local/mongodb/bin
mongod
mongo
以上就是关于“mac下MongoDB没有启动是什么缘故,怎么办好”的相关知识,感谢各位的阅读。