开发者社区> 问答> 正文

db.shutdownServer()报错?报错

在学mongodb。版本是version: 3.0.6

> use admin
switched to db admin
> db.auth('super','super');
1
> show dbs
admin  0.078GB
local  0.078GB
test   0.078GB


> db.shutdownServer();
assert failed : unexpected error: Error: shutdownServer failed: not authorized on admin to execute command { shutdown: 1.0 }
Error: assert failed : unexpected error: Error: shutdownServer failed: not authorized on admin to execute command { shutdown: 1.0 }
    at Error (<anonymous>)
    at doassert (src/mongo/shell/assert.js:11:14)
    at assert (src/mongo/shell/assert.js:20:5)
    at DB.shutdownServer (src/mongo/shell/db.js:212:9)
    at (shell):1:4
2015-09-15T08:08:53.788+0800 E QUERY    Error: assert failed : unexpected error: Error: shutdownServer failed: not authorized on admin to execute command { shutdown: 1.0 }
    at Error (<anonymous>)
    at doassert (src/mongo/shell/assert.js:11:14)
    at assert (src/mongo/shell/assert.js:20:5)
    at DB.shutdownServer (src/mongo/shell/db.js:212:9)
    at (shell):1:4 at src/mongo/shell/assert.js:13
请问这个错误怎么解决?

展开
收起
爱吃鱼的程序员 2020-06-12 11:14:15 825 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    没权限

    notauthorizedonadmintoexecutecommand{shutdown:1.0}

    也看到没有权限,但是为啥没有权限啊?

    db.createUser(
     {
      user:"super",
      pwd:"super",
      roles:
      [
       {role:"userAdminAnyDatabase",db:"admin"}
      ]
     }
    )

    这是有权限的吧!!!为何还是不能关闭!
    2020-06-12 11:14:33
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
SQL Server 2017 立即下载
The state of SQL-on-Hadoop in 立即下载
低代码开发师(初级)实战教程 立即下载