启动MongoDB数据库:
[js] 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:343:13
linux端安装mongodb,启动mongodb 时报错:
无论用哪种方式启动都会,包括下面几种:
上面两种是直接报错,但是下面这一种看似已经启动了(因为可以通过localhost:27017访问到),但是登录的时候还是报错(和上面一样)
解决方案:
sudo mkdir -p /var/lib/mongo
sudo mkdir -p /var/log/mongodb
sudo chown `whoami` /var/lib/mongo
sudo chown `whoami` /var/log/mongodb
# 运行mongodb数据库
mongod --dbpath /var/lib/mongo --logpath /var/log/mongodb/mongod.log --fork
问题就解决啦: