无法使用命令写入模式错误,降级为兼容模式 [英] Cannot use commands write mode error, Degrading to compatibility mode

查看:91
本文介绍了无法使用命令写入模式错误,降级为兼容模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I just play with mongo shell and came across with Cannot use commands write mode, degrading to compatibility mode.

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

I connected to remote mongo server (mongolab) and tried to insert new record to collection by my simple script:

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

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

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

I run script by mongo script.js and got:

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>连接后执行类似的查询时,一切正常.

What is wrong? Additionally when I executed similar query after connected via mongo my.mongolab.com:port/DBname -u <dbuser> -p <dbpassword> everything is OK.

推荐答案

您使用的外壳比与其通信的服务器要新.

You are using a shell that's newer than the server it's communicating with.

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

You can check the server version from the shell via db.version() - to check shell version you use version()

从2.6开始,mongod服务器开始使用新的写入命令,这些命令不同于以前使用的insert/update/remove操作代码(所有内容在

Starting with 2.6 the mongod server started using new write commands which are different than the previously use insert/update/remove op code (this is all described in the MongoDB Wire Protocol).

这是一个无害的信息性"警告.最好使用与服务器相同的Shell版本,以免对此感到疑惑.

This is a harmless "informational" warning. It's a good idea to use the same version shell as the server to avoid wondering about such things though.

这篇关于无法使用命令写入模式错误,降级为兼容模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆