Install and configure password login

  • 1. Download address

  • 2. Create a super administrator

    use admin
    db.createUser({
      user:'root',
      pwd:'root'.roles: [{role:'root',db:'admin'}]
    })
    # Successfully added user: {#"user" : "root"#,"roles": [# {#"role" : "root"#,"db" : "admin"#} #] #}Copy the code
  • 3. Modify the configuration file

    #For Macs :/usr/local/etc/mongod.conf
    #1. Make a copy
      cp mongod.conf mongod_bank.conf
    #2. Add it in mongod
    security:
    	authorization: enabled
    Copy the code
  • 4、停止运行中的mongodb

    use admin;
    db.shutdownServer();
    Copy the code
  • 5. Run the mongodb command in the background

    nohup mongod &
    Copy the code

Create a separate password for the database

  • 1. Create secret orders

    use nest_cms
    db.createUser( {
      user: "nest_cms".pwd: "123456".roles: [{role: "dbOwner".db: "eggcms"}]})Copy the code
  • 2, [the built-in role in directing] (www.cnblogs.com/zzw1787044/…