Mongo报错:couldn‘t connect to server 127.0.0.1:27017, connection attempt failed: SocketException

Mongo 报错信息:

MongoDB shell version v4.4.13
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

原因分析:

通常是由于新手未执行数据库服务器启动命令,就执行连接命令行命令,从而导致连接失败。

解决方法:

1.先启动 mongo 服务:
> mongod
2.另开一个新命令行终端,执行连接命令行:
> mongo

你可能感兴趣的:(问题解决,mongodb,数据库,database)