localhost窗口中的Mongodb错误

时间:2016-01-05 09:48:26

标签: sql node.js mongodb database

我已经从mongodb网站下载了mongodb msi文件,我在C:\ Program Files \ MongoDB \ Server \ 3.2 \ bin中成功安装 我在具有管理员权限的命令提示符下使用命令mongodb 但错误发生在

  

C:\Program Files\MongoDB\Server\3.2\bin>mongo
MongoDB shell version: 3.2.0
connecting to: test
2016-01-05T15:08:52.215+0530 W NETWORK  [thread1] Failed to connect to 127.0.0.1:27017, reason: errno:10061 No connection could be made because the target machine actively refused it.
2016-01-05T15:08:52.229+0530 E QUERY    [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:224:14
@(connect):1:6
exception: connect failed

cmd提示的图片附有here

执行mongod命令后错误就像

  

C:\Program Files\MongoDB\Server\3.2\bin>mongod
2016-01-05T15:06:15.150+0530 I CONTROL  [initandlisten] MongoDB starting : pid=12512 port=27017 dbpath=C:\data\db\ 64-bit host=DESKTOP-3F1GEI5
2016-01-05T15:06:15.161+0530 I CONTROL  [initandlisten] targetMinOS: Windows Vista/Windows Server 2008
2016-01-05T15:06:15.167+0530 I CONTROL  [initandlisten] db version v3.2.0
2016-01-05T15:06:15.171+0530 I CONTROL  [initandlisten] git version: 45d947729a0315accb6d4f15a6b06be6d9c19fe7
2016-01-05T15:06:15.179+0530 I CONTROL  [initandlisten] allocator: tcmalloc
2016-01-05T15:06:15.183+0530 I CONTROL  [initandlisten] modules: none
2016-01-05T15:06:15.186+0530 I CONTROL  [initandlisten] build environment:
2016-01-05T15:06:15.190+0530 I CONTROL  [initandlisten]     distarch: x86_64
2016-01-05T15:06:15.195+0530 I CONTROL  [initandlisten]     target_arch: x86_64
2016-01-05T15:06:15.200+0530 I CONTROL  [initandlisten] options: {}
2016-01-05T15:06:15.238+0530 I STORAGE  [initandlisten] exception in initAndListen: 29 Data directory C:\data\db\ not found., terminating
2016-01-05T15:06:15.246+0530 I CONTROL  [initandlisten] dbexit:  rc: 100

1 个答案:

答案 0 :(得分:5)

mongod direct命令包含一些默认参数

mongod --dbpath=C:\data\db\   --port=27017

所以在c中创建一个文件夹数据,然后在其中创建一个db文件夹,然后运行命令

mongod

您的服务器将处于运行状态,现在使用

连接到它
mongo --port=27017    

如果有问题,那么这对您有用,然后发表评论