一、报错问题
当启动mongo时,报错:
Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
如下:
connecting to: test 2021-07-21T16:49:42.932+0800 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused 2021-07-21T16:49:42.933+0800 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
二、报错原因
一般情况下,是因为在数据库mongo的存放目录data下,产生了mongo.lock文件,导致mongo无法进入
三、解决方法
1、进入mongo的存放目录
#1、 进入目录 cd /usr/local/mongodb/ #2、执行如下命令 进行修复 ./bin/mongod --repair #3、然后重启mongo /usr/local/mongodb/bin/mongod -c /etc/monogdb.conf #4、然后在执行mongo命令 cd /usr/local/mongodb/bin ./mongo
如果上述修复还存在问题,不能解决,则直接删除mongo.lock文件
#1、删除lock文件 rm -f /usr/local/mongodb/data/db/mongod.lock #2、重启mongo /usr/local/mongodb/bin/mongod -c /etc/monogdb.conf
转载:https://blog.csdn.net/xu710263124/article/details/118971172
标签:127.0,Mongo,0.1,mongodb,connect,mongo,usr From: https://www.cnblogs.com/zpzp/p/17120385.html