mongo导入js脚本(Mongo命令)遇到的问题

2022-04-21  本文已影响0人  mtinsky

记录在linux下执行mongo导入js脚本(Mongo命令)遇到的问题

  1. Unauthorized
MongoDB shell version v3.4.23
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.23
2022-04-21T10:35:57.062+0800 E QUERY    [thread1] Error: error: {
    "ok" : 0,
    "errmsg" : "not authorized on test to execute command { xxxxxxx }",
    "code" : 13,
    "codeName" : "Unauthorized"
} :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DBCommandCursor@src/mongo/shell/query.js:702:1
DBQuery.prototype._exec@src/mongo/shell/query.js:117:28
DBQuery.prototype.hasNext@src/mongo/shell/query.js:288:5
@(shell):1:7
2022-04-21T10:35:57.063+0800 E QUERY    [thread1] TypeError: this._cursor is null :
DBQuery.prototype.close@src/mongo/shell/query.js:681:5
@(shell):1:1
bye
  1. unterminated string literal
MongoDB shell version v3.4.23
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.23
2022-04-21T09:11:06.308+0800 E QUERY    [thread1] SyntaxError: unterminated string literal @(shellhelp1):1:24
error2:SyntaxError: unterminated string literal @(shellhelp1):1:24

bye
  1. console is not defined
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.23
2022-04-21T09:29:10.270+0800 E QUERY    [thread1] ReferenceError: console is not defined :
@(shell):31:2
bye
  1. Mongodb的js脚本操作多个数据库
# 加上有数据库dba和dbb,分别有集合ca,cb
db.getSiblingDB( 'dba' ).ca.find();
db.getSiblingDB( 'dbb' ).cb.find();
上一篇下一篇

猜你喜欢

热点阅读