[英]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.