Create a MongoDB user from commandline

后端 未结 3 861
悲哀的现实
悲哀的现实 2021-02-19 04:23

I have set up a MongoDB database with an admin user that has only administrative rights, not read or write access to databases.

What I now would want to do

3条回答
  •  -上瘾入骨i
    2021-02-19 05:26

    Solved it by putting the commands

    use dummydb
    db.addUser('dummyuser', 'dummysecret')
    

    into a .js file, and then ran MongoDB by calling:

    $ mongo admin -u admin -p admin < setupMongoDB.js
    

    That's it :-)

提交回复
热议问题