wdnmd

mongodb因为上一次异常关闭导致锁死,连接失败

之前一直可以用,但是突然在启动node,服务端的时候报错,(下面的错误信息都是复制的网上的报错信息,刚才忘记截图错误信息了,现在已经解决问题)

这是服务端的报错

(node:17453) UnhandledPromiseRejectionWarning: MongoNetworkError: failed to connect to server [localhost:27017] on first connect [MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017] at Pool. (/home/akbar/projecttt/node_modules/mongodb-core/lib/topologies/server.js:564:11) at Pool.emit (events.js:182:13) at Connection. (/home/akbar/projecttt/node_modules/mongodb-core/lib/connection/pool.js:317:12) at Object.onceWrapper (events.js:273:13) at Connection.emit (events.js:182:13) at Socket. (/home/akbar/projecttt/node_modules/mongodb-core/lib/connection/connection.js:246:50) at Object.onceWrapper (events.js:273:13) at Socket.emit (events.js:182:13) at emitErrorNT (internal/streams/destroy.js:82:8) at emitErrorAndCloseNT (internal/streams/destroy.js:50:3) at process._tickCallback (internal/process/next_tick.js:63:19) (node:17453) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:17453) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

 

这是数据库的报错

Unable to connect to server 127.0.0.1:27017: 未将对象引用设置到对象的实例。.

 

当时没想到错误原因, 后来在网上找了很久,发现了可能的原因,想了想好想确实有可能是因为上一次关闭异常,导致出现了问题,网上给的解决方案是删除mongdb的data文件夹中的一个

mongodb.lock文件,找到后发现删除不了,需要先打开任务管理器,找到mongodb的服务,停止服务,删除后再开启服务。

这个时候又报错了 

Unable to connect to server 127.0.0.1:27017: Invalid credential for database

 

这个就比较简单了,只需要修改数据库的信息,将原来设置的username,password删除即可

 

posted @ 2020-06-08 08:47  FreshChick  阅读(688)  评论(0编辑  收藏  举报