• MongoDB 用户管理


    Mongodb账户权限配置

    第一步 创建超级管理用户

    这是整个数据库(所有数据库的超级管理员,可以给每个数据库设置管理员)

    use admin
    
    db.createUser({
      user:'admin',
      pwd:'123456',
      roles:[{role:'root',db:'admin'}] // root表示超级管理员
    })

    第二步 修改Mongodb数据库配置文件

    找到Mongodb的安装目录到bin目录,里面有个文件mongod.cfg,修改security:authorization: enabled,开启用户权限

    # mongod.conf
    
    # for documentation of all options, see:
    #   http://docs.mongodb.org/manual/reference/configuration-options/
    
    # Where and how to store data.
    storage:
      dbPath: C:Program FilesMongoDBServer4.0data
      journal:
        enabled: true
    #  engine:
    #  mmapv1:
    #  wiredTiger:
    
    # where to write logging data.
    systemLog:
      destination: file
      logAppend: true
      path:  C:Program FilesMongoDBServer4.0logmongod.log
    
    # network interfaces
    net:
      port: 27017
      bindIp: 127.0.0.1
    
    
    #processManagement:
    
    #security:
    
    #operationProfiling:
    
    #replication:
    
    #sharding:
    
    ## Enterprise-Only Options:
    
    #auditLog:
    
    #snmp:

     注意前面是两个空格

    # mongod.conf
    
    # for documentation of all options, see:
    #   http://docs.mongodb.org/manual/reference/configuration-options/
    
    # Where and how to store data.
    storage:
      dbPath: C:Program FilesMongoDBServer4.0data
      journal:
        enabled: true
    #  engine:
    #  mmapv1:
    #  wiredTiger:
    
    # where to write logging data.
    systemLog:
      destination: file
      logAppend: true
      path:  C:Program FilesMongoDBServer4.0logmongod.log
    
    # network interfaces
    net:
      port: 27017
      bindIp: 127.0.0.1
    
    
    #processManagement:
    
    security: 
      authorization: enabled
    
    #operationProfiling:
    
    #replication:
    
    #sharding:
    
    ## Enterprise-Only Options:
    
    #auditLog:
    
    #snmp:

    第三步 重启mongodb服务

    第四步 用超级管理员账户连接数据库

    mongo admin -u 用户名 -p 密码

    第五步 给eggcms数据库创建一个用户,只能访问eggcms不能访问其他数据库

  • 相关阅读:
    Cryptocurrency Security Compliance
    HOW TO ACHIEVE CRYPTOCURRENCY SECURITY STANDARD (CCSS) COMPLIANCE
    Cryptocurrency Security Guide@BitIRA
    How to Trade Cryptocurrency – The Complete Guide
    7 Things I Learned From Porting a C Crypto Library to Rust
    25 Places To Find Quantitative Trading Strategies
    JavaScript-Runoob-AJAX:服务器响应
    JavaScript-Runoob-AJAX:向服务器发送请求
    JavaScript-Runoob-AJAX:创建 XMLHttpRequest 对象
    JavaScript-Runoob-AJAX:AJAX 实例
  • 原文地址:https://www.cnblogs.com/LO-ME/p/10872989.html
Copyright © 2020-2023  润新知