简体   繁体   English

当我尝试在命令提示符下连接到mongodb时,它将显示错误如何解决?

[英]When I try to connect to mongodb in the command prompt it will display an error how to fix it?

events.js:160 throw er; events.js:160 throw er; // Unhandled 'error' event //未处理的“错误”事件

  ^

MongoError: failed to connect to server [localhost:27017] on first connect [MongoError: connect ECONNREFUSED 127.0.0.1:27017] MongoError:首次连接时无法连接到服务器[localhost:27017] [MongoError:连接ECONNREFUSED 127.0.0.1:27017]

at Pool.<anonymous> 

(C:\\Users\\DELL\\Desktop\\meanapp\\server\\node_modules\\mongodb- (C:\\用户\\ DELL \\桌面\\ meanapp \\服务器\\ node_modules \\ mongodb-

core\\lib\\topologies\\server.js:328:35) 芯\\ lib中\\拓扑\\ server.js:328:35)

at emitOne (events.js:96:13)

at Pool.emit (events.js:188:7)

at Connection.<anonymous> 

(C:\\Users\\DELL\\Desktop\\meanapp\\server\\node_modules\\mongodb- (C:\\用户\\ DELL \\桌面\\ meanapp \\服务器\\ node_modules \\ mongodb-

core\\lib\\connection\\pool.js:274:12) 芯\\ lib中\\连接\\ pool.js:274:12)

The error is saying that the connection have been refused (ECONNREFUSED). 该错误表明连接已被拒绝(ECONNREFUSED)。 There is no endpoint listening on 127.0.0.1:27017 没有端点在127.0.0.1:27017上监听

Mongo have a client-server architecture. Mongo具有客户端-服务器架构。 Before connecting to the database, you need to start the database server. 连接到数据库之前,您需要启动数据库服务器。 First, create a folder to store the data files. 首先,创建一个文件夹来存储数据文件。 Then, from command prompt, go to where your mongo installations resides and write: 然后,在命令提示符下,转到您的mongo安装所在的位置并输入:

mongod --port 27017 --dbpath C:\path_to_data_folder

https://docs.mongodb.com/manual/tutorial/manage-mongodb-processes/ https://docs.mongodb.com/manual/tutorial/manage-mongodb-processes/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当我尝试连接到 mongodb 时出现此错误 - when i try to connect to mongodb get this error 当我尝试连接到 mongodb 时出现此错误 - I get this error when i try to connect to mongodb 当我尝试连接到 mongodb 时出现这些错误 - when I try to connect to mongodb I got these error 尝试在Node.js中连接到Postgresql池时如何修复ECONNREFUSED错误 - How to fix an ECONNREFUSED error when try to connect to a postgresql pool in nodejs 尝试连接到MongoDB Atlas时如何解决密码错误? - How to fix password error when trying to connect to MongoDB Atlas? 当我尝试在 Windows 命令提示符下运行 `npm run test` 时出错 - Error when I try to run `npm run test` in windows command prompt 当我尝试在 meteor 上运行 vulcan 时,如何解决此错误? 它在体内给出 - How do I fix this error when I try to run vulcan on meteor? It is given in the body 当我尝试使用 uuid package 时,如何修复“意外令牌'导出'”错误? - How do I fix “unexpected token 'export'” error when I try to use uuid package? 错误:connect ECONNREFUSED::1:3306 是当我尝试在 nestjs 中使用 typeorm 时 - Error: connect ECONNREFUSED ::1:3306 is when i try to use typeorm in nestjs 当我尝试使用npm start命令运行React App时出错 - Error when I try run a React App with npm start command
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM