当前位置:  开发笔记 > 编程语言 > 正文

MongoDB新手无法运行命令mongo

如何解决《MongoDB新手无法运行命令mongo》经验,为你挑选了5个好方法。

我试图运行MongoDB:

   E:\mongo\bin>mongod
    mongod --help for help and startup options
    Sun Nov 06 18:48:37
    Sun Nov 06 18:48:37 warning: 32-bit servers don't have journaling enabled by default. Please use --journal if you want durability.
    Sun Nov 06 18:48:37
    Sun Nov 06 18:48:37 [initandlisten] MongoDB starting : pid=7108 port=27017 dbpath=/data/db 32-bit host=pykhmer-PC
    Sun Nov 06 18:48:37 [initandlisten]
    Sun Nov 06 18:48:37 [initandlisten] ** NOTE: when using MongoDB 32 bit, you are limited to about 2 gigabytes of data
    Sun Nov 06 18:48:37 [initandlisten] **       see http://blog.mongodb.org/post/137788967/32-bit-limitations
    Sun Nov 06 18:48:37 [initandlisten] **       with --journal, the limit is lower
    Sun Nov 06 18:48:37 [initandlisten]
    Sun Nov 06 18:48:37 [initandlisten] db version v2.0.1, pdfile version 4.5
    Sun Nov 06 18:48:37 [initandlisten] git version: 3a5cf0e2134a830d38d2d1aae7e88cac31bdd684
    Sun Nov 06 18:48:37 [initandlisten] build info: windows (5, 1, 2600, 2, 'Service Pack 3') BOOST_LIB_VERSION=1_42
    Sun Nov 06 18:48:37 [initandlisten] options: {}
    Sun Nov 06 18:48:37 [initandlisten] exception in initAndListen: 10296 dbpath (/data/db) does not exist, terminating
    Sun Nov 06 18:48:37 dbexit:
    Sun Nov 06 18:48:37 [initandlisten] shutdown: going to close listening sockets...
    Sun Nov 06 18:48:37 [initandlisten] shutdown: going to flush diaglog...
    Sun Nov 06 18:48:37 [initandlisten] shutdown: going to close sockets...
    Sun Nov 06 18:48:37 [initandlisten] shutdown: waiting for fs preallocator...
    Sun Nov 06 18:48:37 [initandlisten] shutdown: closing all files...
    Sun Nov 06 18:48:37 [initandlisten] closeAllFiles() finished
    Sun Nov 06 18:48:37 dbexit: really exiting now

E:\mongo\bin>mongo
MongoDB shell version: 2.0.1
connecting to: test
Sun Nov 06 18:48:42 Error: couldn't connect to server 127.0.0.1 shell/mongo.js:84
exception: connect failed

E:\mongo>ls
GNU-AGPL-3.0  README  THIRD-PARTY-NOTICES  bin  data

我正在查看http://www.mongodb.org/display/DOCS/Quickstart+Windows 并按照说明操作.谁能告诉我运行MongoDB有什么问题(我使用的是Windows 7)?



1> Fatih Acet..:

安装MongoDB后,您应手动创建数据文件夹.

By default MongoDB will store data in /data/db, 
but it won't automatically create that directory. To create it, do:

$ sudo mkdir -p /data/db/
$ sudo chown `id -u` /data/db

You can also tell MongoDB to use a different data directory,
with the --dbpath option.

有关更多详细信息,请访问MongoDB wiki页面.


这应该是答案 - 它工作,然后"阅读文档"更有帮助.

2> kirpit..:

我认为你的日志输出清楚地说明了它;

exception in initAndListen: 10296 dbpath (/data/db) does not exist, terminating

您可以简单地创建此目录或更好地将其定义为配置文件中的配置值,然后将其用作mongod -f C:\path\to\your\mongodb.conf.


默认情况下,MongoDB查找:c:\ data\db文件夹,因此您也可以只创建该目录结构,并且MongoDB数据库进程不会对您大喊大叫.
别担心.只是摆脱那个windowz的东西,这将使你更熟悉软件开发..

3> Socratees Sa..:

像这样明确指定数据库路径,看看是否能解决问题.

mongod --dbpath data/db



4> 小智..:
mongod --dbpath "c://data/db"

运行上面的代码,这将启动服务器.



5> Zeeshan Akht..:

对于Windows 7

您可以为指定的备用路径\data\dbDBPATH设置为mongod.exe,

如下例所示:

c:\mongodb\bin\mongod.exe --dbpath c:\mongodb\data\db

要么

您可以通过配置文件设置dbpath.

推荐阅读
雯颜哥_135
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有