运行 `mongo` 在命令行中给出错误

Running `mongo` in the command line is giving error

我正在尝试启动 MERN 应用程序,我已经安装了 mongo 和任何相关的东西。但是当我在终端中 运行 mongo 时,会出现以下内容。 我已经全面看过了,但解决方案对我没有帮助。我也在 运行宁 Ubuntu 20.04.

MongoDB shell version v4.4.3
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
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:374:17
@(connect):2:6
exception: connect failed
exiting with code 1

运行

解决了这个问题
$ sudo rm -rf /tmp/mongodb-27017.sock

$ sudo service mongod start