zoukankan      html  css  js  c++  java
  • Mongodb3安装授权

    (1)

    mongodb 官网下载解压包
    mongodb-win32-x86_64-3.0.7.zip
    解压释放在d盘,目录为mongodb,接下来手动创建data文件夹和log文件夹分别用于存放数据和日志。

    (2)安装mongodb服务(不带auth参数安装)
    cmd进入shell命令窗口

    C:UsersAdministrator>d:

    D:>cd D:mongodbin

    mongod --logpath D:mongodblogmongodb.log --logappend --dbpath D:mongodbdata --serviceName MongoDB --install

    紧接着执行服务启动命令:

    net start MongoDB

    (3)

    cmd进入shell命令窗口

    C:UsersAdministrator>d:

    D:>cd D:mongodbin

    D:mongodbin>mongo

    MongoDB shell version: 3.0.7
    connecting to: test

    > use admin
    switched to db admin
    > db.createUser({user: "admin",pwd: "123456",roles: ["root"]})
    Successfully added user: { "user" : "admin", "roles" : [ "root" ] }

    > use admin
    switched to db admin
    > var schema = db.system.version.findOne({"_id" : "authSchema"})
    > schema.currentVersion=3
    > db.system.version.save(schema)

    > use admin
    switched to db admin
    > db.createUser({user:"sa",pwd:"123456",roles:[{role:"userAdminAnyDatabase",db:"admin"}]})

    > use mtc
    switched to db mtc
    > db.createUser({user:"root",pwd:"123456",roles:[{role:"readWrite",db:"mtc"}]})

    > db.auth("root","rtqw998358")

    > exit

    (4)执行服务停止命令
    net stop MongoDB
    紧接着执行服务安装命令(带auth参数):
    mongod --logpath D:mongodblogmongodb.log --logappend --dbpath D:mongodbdata --serviceName MongoDB --auth --install
    然后执行服务启动命令:
    net start MongoDB

    (5)然后就能通过的客户端工具mongodb vue进行远程授权连接啦!

  • 相关阅读:
    TestNg 2.套件测试
    JBPM工作流
    Spring 事务详解
    数据库事务隔离级别及传播行为
    Spring AspectJ基于注解的AOP实现
    Spring 通知(Advice)和顾问(Advisor)
    Spring 代理模式及AOP基本术语
    Spring之BeanFactory及Bean生命周期
    Spring 02多种注入方式和注解实现DI
    Spring 01基础
  • 原文地址:https://www.cnblogs.com/fx2008/p/5034902.html
Copyright © 2011-2022 走看看