我试图运行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)?
答案 0 :(得分:162)
安装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.
答案 1 :(得分:73)
我认为你的日志输出清楚地表明了它;
exception in initAndListen: 10296 dbpath (/data/db) does not exist, terminating
您可以简单地创建此目录,或者更好地创建define it作为配置文件中的配置值,然后将其用作mongod -f C:\path\to\your\mongodb.conf
。
答案 2 :(得分:27)
明确指定数据库路径,并查看是否能解决问题。
mongod --dbpath data/db
答案 3 :(得分:20)
mongod --dbpath "c://data/db"
运行上面的代码,这将启动服务器。
答案 4 :(得分:5)
对于 Windows 7
您可以使用 mongod.exe的\data\db
指定备用路径,
,如下例所示:
c:\mongodb\bin\mongod.exe --dbpath c:\mongodb\data\db
或
您可以通过配置文件设置dbpath 。
答案 5 :(得分:4)
检查数据库数据文件的路径是否存在;):
Sun Nov 06 18:48:37 [initandlisten] initAndListen中的异常:10296 dbpath(/ data / db)不存在,终止
答案 6 :(得分:2)
这对我有用(如果它适用于你也看到锁文件):
first>youridhere@ubuntu:/var/lib/mongodb$ sudo service mongodb start
then >youridhere@ubuntu:/var/lib/mongodb$ sudo rm mongod.lock*
答案 7 :(得分:2)
经过多次尝试,这对我来说非常适用于 Windows 7 环境:
最初将所有MongDB源复制到的目录都有这样的视图:
bsondump.exe
mongo.exe
mongod.exe
mongod.pdb
mongodump.exe
mongoexport.exe
mongofiles.exe
mongoimport.exe
mongooplog.exe
mongoperf.exe
mongorestore.exe
mongos.exe
mongos.pdb
mongostat.exe
mongotop.exe
您只需添加数据目录和 db 目录嵌套(data / db) 最终视图应如下所示:
data
bsondump.exe
mongo.exe
mongod.exe
mongod.pdb
mongodump.exe
mongoexport.exe
mongofiles.exe
mongoimport.exe
mongooplog.exe
mongoperf.exe
mongorestore.exe
mongos.exe
mongos.pdb
mongostat.exe
mongotop.exe
只需键入MongoDB源和data / db dirs存在此目录的目录:
C:\my_mongo_dir\bin>mongod --dbpath .\data\db
答案 8 :(得分:1)
在主(windows)分区中创建data / db目录:
C:\> mkdir \data
C:\> mkdir \data\db
然后转到你的mongo_directory / bin并运行mongod.exe:
C:\> cd \my_mongo_dir\bin
C:\my_mongo_dir\bin> mongod
不要关闭这个窗口
现在在另一个命令提示符窗口中运行Mongo:
C:\> cd \my_mongo_dir\bin
C:\my_mongo_dir\bin> mongo
(记住,你必须保持其他窗口打开)
这解决了我的问题。
答案 9 :(得分:1)
同时检查您是否已将Mongo安装为Windows服务以及是否正在运行。这也很重要。因此可能存在冲突。
答案 10 :(得分:1)
在工作目录中创建文件夹结构数据/ db然后使用“mongod --dbpath data / db”启动mongodb工作正常
答案 11 :(得分:1)
如果您使用的是Windows,则应该创建一个startup.bat
,方便得多:
C:\mongodb\mongodb-win32-x86_64-eiditon\bin\mongod.exe --dbpath C:\mongodb\data
只有dbclick startup.bat和mongodb将使用C:\mongodb\data
作为其数据文件夹运行。
答案 12 :(得分:0)
您只需要在C:中创建目录。如C:\ data \ db \
现在就开始使用mongoDB:
C:\Users\gi.gupta>"c:\Program Files\MongoDB\Server\3.2\bin\mongod.exe"
2016-05-03T10:49:30.412+0530 I CONTROL [main] Hotfix KB2731284 or later update is not installed, will zero-out data files
2016-05-03T10:49:30.414+0530 I CONTROL [initandlisten] MongoDB starting : pid=7904 port=27017 dbpath=C:\data\db\ 64-bit host=GLTPM-W036
2016-05-03T10:49:30.414+0530 I CONTROL [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2016-05-03T10:49:30.414+0530 I CONTROL [initandlisten] db version v3.2.6
2016-05-03T10:49:30.414+0530 I CONTROL [initandlisten] git version: 05552b562c7a0b3143a729aaa0838e558dc49b25
2016-05-03T10:49:30.414+0530 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1p-fips 9 Jul 2015
2016-05-03T10:49:30.414+0530 I CONTROL [initandlisten] allocator: tcmalloc
2016-05-03T10:49:30.414+0530 I CONTROL [initandlisten] modules: none
2016-05-03T10:49:30.414+0530 I CONTROL [initandlisten] build environment:
2016-05-03T10:49:30.414+0530 I CONTROL [initandlisten] distmod: 2008plus-ssl
2016-05-03T10:49:30.414+0530 I CONTROL [initandlisten] distarch: x86_64
2016-05-03T10:49:30.414+0530 I CONTROL [initandlisten] target_arch: x86_64
2016-05-03T10:49:30.414+0530 I CONTROL [initandlisten] options: {}
2016-05-03T10:49:30.427+0530 I - [initandlisten] Detected data files in C:\data\db\ created by the 'wiredTiger' storage engine, so setting the active storage engine to
2016-05-03T10:49:30.429+0530 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=1G,session_max=20000,eviction=(threads_max=4),config_base=false,statistics=(f
chive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
2016-05-03T10:49:30.998+0530 I NETWORK [HostnameCanonicalizationWorker] Starting hostname canonicalization worker
2016-05-03T10:49:30.998+0530 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory 'C:/data/db/diagnostic.data'
2016-05-03T10:49:31.000+0530 I NETWORK [initandlisten] waiting for connections on port 27017
2016-05-03T10:49:40.766+0530 I NETWORK [initandlisten] connection accepted from 127.0.0.1:57504 #1 (1 connection now open)
然后它将作为后台服务运行。
答案 13 :(得分:0)
如果您使用的是Windows 7 / 7+。
您可以尝试以下方法。
在计算机的控制面板中检查安装是否正确。
现在转到目录和您安装MongoDB的位置。理想情况下,它将位于
C:\ Program Files \ MongoDB \ Server \ 3.6 \ bin
然后在命令提示符或IDE的终端中。导航到上述路径(最好是保存文件),然后输入
mongod --dbpath
应该没问题!
答案 14 :(得分:0)
mongo README帮助文件给出的最简单方法
正在运行
对于命令行选项,调用:
$ ./mongod --help
要运行单个服务器数据库:
$ sudo mkdir -p /data/db
$ ./mongod
$
$ # The mongo javascript shell connects to localhost and test database by default:
$ ./mongo
> help
如果您使用的是Windows,转到包含mongo.exe的目录
使用以下命令,(我在与我分享)
C:\Program Files\MongoDB\Server\3.6\bin>mkdir \data
C:\Program Files\MongoDB\Server\3.6\bin>mkdir \data\db
C:\Program Files\MongoDB\Server\3.6\bin>mongod ## this will start your mongoDB server
现在,您需要运行另一个CMD提示符,并转到您拥有mongo的目录,然后运行它
C:\Program Files\MongoDB\Server\3.6\bin>mongo ## this will start your mongoDB client
希望对您有所帮助:)
如果它不起作用,请以管理员身份运行CMD