When creating first admin user on mongdb cluster getting error “couldn't add user: not authorized on admin to execute command”

后端 未结 6 907
既然无缘
既然无缘 2021-02-04 19:10

I am using mongoDB Cluster with version 3.4 in google cloud compute engine, actually past week my database got attacked by hackers that\'s why i thought about using authorizatio

6条回答
  •  爱一瞬间的悲伤
    2021-02-04 20:09

    You have to change your mongod.conf file to disable authorization before creating such admin user

    security:
      authorization: disabled
    

    After that, restart the mongod service and open mongodb shell to create the admin user

    use admin
    db.createUser({user:"RootAdmin",pwd:"blahblah",roles:["root"]})
    

    Remember to enable authorization back on after creating user.

提交回复
热议问题