【发布时间】:2018-12-10 04:32:51
【问题描述】:
在配置文件中我有:
systemLog:
destination: file
logAppend: true
path: c:\data\log\mongod.log
storage:
dbPath: c:\data\db
journal:
enabled: true
replication:
replSetName: "rs0"
net:
bindIp: 127.0.0.1
port: 27017
security:
authorization: enabled
我正在尝试使用mongod 进程进行连接,例如documentation:
C:\Program Files\MongoDB\Server\3.6\bin> mongod --auth --dbpath /data/db --config C:\Program Files\MongoDB\Server\3.6\mongod.cfg
得到:
读取配置文件时出错:没有这样的文件或目录
尝试 'C:\Program Files\MongoDB\Server\3.6\bin\mongod.exe --help' 了解更多信息
然后尝试使用引号
C:\Program Files\MongoDB\Server\3.6\bin> mongod --auth --dbpath /data/db --config "C:\Program Files\MongoDB\Server\3.6\mongod.cfg"
得到:
2018-07-02T02:49:21.272+0300 I CONTROL [main] 日志文件“c:\data\log\mongod.log”存在;移至“c:\data\log\mongod.log.2018-07-01T23-49-21”。
如果我正在写这个 sn-p(没有配置),一切都很好:
mongod --auth --dbpath /data/db --bind_ip 127.0.0.1
【问题讨论】:
-
为什么您认为在路径周围添加引号后仍然有问题?该消息只是告诉您
mongod旋转了日志文件。而且由于您的配置确实指定了一个日志文件,我希望您在控制台上看到的所有输出都转到该日志。 -
@AnsgarWiechers 因为那时我无法通过
mongo使用mongo --port 27017 -u "myuser" -p "mypassword" --authenticationDatabase "admin"进程查看我的数据库 -
@AnsgarWiechers
show dbs->2018-07-02T14:34:47.242+0300 E QUERY [thread1] Error: listDatabases failed:{ "ok" : 0, "errmsg" : "not master and slaveOk=false", "code" : 13435, "codeName" : "NotMasterNoSlaveOk" } : _getErrorWithCode@src/mongo/shell/utils.js:25:13 Mongo.prototype.getDBs@src/mongo/shell/mongo.js:65:1 shellHelper.show@src/mongo/shell/utils.js:849:19 shellHelper@src/mongo/shell/utils.js:739:15 @(shellhelp2):1:1。show collections同样的错误 -
你的配置文件指定了replication set,你的守护进程没有从命令行启动。
-
我认为您需要在启动 Mongo shell 时调用它(请参阅 Ed Harris 提供的答案)。不过,我在 MongoDB 方面没有太多经验。
标签: mongodb powershell