mongo进入报错

问题:在cmd中,输入命令mongo就报错

couldn’t connect to server 127.0.0.1:27017
在这里插入图片描述
应该是没有启动服务的原因,打开服务,并没有发现MongoDB这个服务
在这里插入图片描述

解决方法

还是在cmd中,输入下面两个命令

(1)删除服务

sc delete MongoDB

(2)创建服务,注意创建的位置

sc create MongoDB binPath= “C:\Program Files\MongoDB\Server\4.0\bin\mongod.exe --service --config=D:\mongodb\mongo.config”

最后打开服务,启动服务
在这里插入图片描述
再次进入mongo,成功了
在这里插入图片描述