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

后端 未结 6 965
既然无缘
既然无缘 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 19:49

    edit vim /lib/systemd/system/mongod.service

    remove --auth 
    restart
    
    #ExecStart=/usr/bin/mongod --quiet --auth   --config /etc/mongod.conf
    ExecStart=/usr/bin/mongod --quiet  --config /etc/mongod.conf
    use admin
    db.createUser({user:"RootAdmin",pwd:"blahblah",roles:["root"]})
    

提交回复
热议问题