在使用mongodb的时候,出现如下异常:
2017-09-22T11:36:26.663+0800 I STORAGE [initandlisten] exception in initAndListen:72 Requested option conflicts with current storage engine option for directoryPerDB; you requested false but the current server storage is already set to true and cannot be changed
解决方法:
1.以管理员身份进入dos
win+s,输入cmd,鼠标右键选择“以管理员身份运行”,然后切到mongodb的bin目录下
2. remove 掉原有的服务
F:\mongoDB\bin>mongod --remove
3. 去掉--directoryperdb
F:\mongoDB\bin>
mongod --config F:\mongoDB\data\mongod.cfg --serviceName MongoDB --intall(如果没有mongod.cfg文件,请看下面的配置) 注: 配置mongod.cfg文件-->直接在data目录下创建名为mongod.cfg文件,内容如下: ## 数据库文件目录 dbpath=F:/mongoDB/data ## 日志目录 logpath=F:/mongoDB/log/mongo.log diaglog=3
4.net start MongoDB