mongodb/mongoose 的本地数据库链接不上
mongodb/mongoose的本地数据库链接不上,shell里的提示如下,这是什么原因?
Error: failed to connect to [127.0.0.1:27017]
at null.<anonymous> (/home/alfred/housemap1.0/node_modules/session-mongoose/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:540:74)
at EventEmitter.emit (events.js:106:17)
at null.<anonymous> (/home/alfred/housemap1.0/node_modules/session-mongoose/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:140:15)
at EventEmitter.emit (events.js:98:17)
at Socket.<anonymous> (/home/alfred/housemap1.0/node_modules/session-mongoose/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection.js:478:10)
at Socket.EventEmitter.emit (events.js:95:17)
at net.js:441:14
at process._tickCallback (node.js:415:13)
4 回复
先启动,才能连接
先启动。 Stop1: mongod -dbpath 你的数据库目录 Stop2:然后就是你要进行的链接操作
应该是本地数据库服务器没启动. 初学者常见这种问题, 只安装了mongodb-native driver for nodejs, 而没有安装mongodb server, 或者没有启动Mongodb server. linux下请用service mongod start
启动mongodb server