gpt4 book ai didi

mongodb - 无法使用命令写入模式错误,降级到兼容模式

转载 作者:IT老高 更新时间:2023-10-28 13:05:04 25 4
gpt4 key购买 nike

我只是在玩 mongo shell,遇到了 Cannot use commands write mode, degrading to compatibility mode .

我连接到远程 mongo 服务器 (mongolab) 并尝试通过我的简单脚本将新记录插入到集合中:

// script.js
db = connect(host + ":" + port +"/" + dbName);
db.auth(username, password);

db.test2.insert({ item: "card", qty: 15 });

我通过 mongo script.js 运行脚本并得到:

MongoDB shell version: 2.6.3
connecting to: test
connecting to: my.mongolab.com:port/DBname
Cannot use commands write mode, degrading to compatibility mode

怎么了?此外,当我通过 mongo my.mongolab.com:port/DBname -u <dbuser> -p <dbpassword> 连接后执行类似查询时一切正常。

最佳答案

您使用的 shell 比与之通信的服务器更新。

您可以通过 db.version() 从 shell 检查服务器版本 - 检查您使用的 shell 版本 version()

从 2.6 开始,mongod 服务器开始使用新的写入命令,这些命令不同于以前使用的插入/更新/删除操作码(所有这些都在 MongoDB Wire Protocol 中进行了描述)。

这是一个无害的“信息性”警告。不过,最好使用与服务器相同的 shell 版本以避免对此类问题感到疑惑。

关于mongodb - 无法使用命令写入模式错误,降级到兼容模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24916320/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com