mongodb 未在 ubuntu 18.04 上启动 [英] mongodb not starting on ubuntu 18.04
问题描述
我在 Windows 10 上运行 ubuntu 18.04.我在 cli 上运行 'mongod' 并且 mongodb 正常启动.然后我尝试运行mongo"并收到此错误:
I'm running ubuntu 18.04 on windows 10. I run 'mongod' on cli and mongodb starts normally. I then try to run 'mongo' and I get this error :
MongoDB shell version v4.0.2
connecting to: mongodb://127.0.0.1:27017
2018-09-01T20:30:37.462+0800 E QUERY [js] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect@src/mongo/shell/mongo.js:257:13
@(connect):1:6
exception: connect failed.
我不明白一个是如何工作的,而另一个则不是.我确实认为这是来自文件权限或本地主机的问题.
I don't understand how one works and the other doesn't. I do think it is from either file permissions or an issue with the localhost.
推荐答案
这可能是两件事
1.) 确保您已设置/data/db 目录.
1.) Make sure you have the /data/db directory set up.
2.) 使用 sudo 启动 mongodb
2.) start mongodb with sudo
sudo start mongodb
或
sudo service mongodb start
3.) 您可能需要删除锁定文件,请尝试以下操作:
3.) You might have to remove a lock file try the following:
sudo rm /var/lib/mongodb/mongod.lock
4.) 修复你的 mongodb 实例
4.) Repair your mongodb instance
sudo mongod --repair
5.) 尝试运行 mongo 控制台:
5.) Try running the mongo console:
mongo
6.)检查mongodb实例的状态
6.)Check the status of the mongodb instance
sudo status mongodb
如果这些不起作用,我知道 DigitalOcean 有一个很棒的教程,我已经链接了 Digital_Ocean_Tutorial
If these don't work I know DigitalOcean has a great tutorial which I have linked Digital_Ocean_Tutorial
这篇关于mongodb 未在 ubuntu 18.04 上启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!