感谢您的到来,公平地说,我确实有一个解决方案,但这只是暂时的。每次打开电脑时,它都会重复执行,而且有点烦人。所以如果有人有更永久的解决方案,请在此处上传。
错误如下:
`MongoDB shell version v4.4.6
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
临时解决办法是,在“sudo su”之后执行以下操作:
chown -R mongodb:mongodb /var/lib/mongodb
chown mongodb:mongodb /tmp/mongodb-27017.sock
sudo service mongod restart