zoukankan      html  css  js  c++  java
  • centos7安装mongodb4.2.15教程

    环境:centos 7

    版本:mongodb 4.2.15

    1、下载安装

    wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-4.2.15.tgz

    tar -xzf mongodb-linux-x86_64-rhel70-4.2.15.tgz

    mv mongodb-linux-x86_64-rhel70-4.2.15 /usr/local/mongodb

    2、创建目录

    mkdir -p /data/mongodb/{db,logs}

    3、配置文件

    vim /data/mongodb/27017.conf

    systemLog:

      destination: file

      logAppend: true

      path: /data/mongodb/logs/27017.log

     

    storage:

      dbPath: /data/mongodb/db

      journal:

        enabled: true

     

    processManagement:

      fork: true

      pidFilePath: /data/mongodb/27017.pid

     

    net:

      port: 27017

      bindIp: 0.0.0.0

     

    security:

      authorization: enabled               #认证

     

    fork: false   前台启动

    fork: true    放入后台启动

     4、启动

    /usr/local/mongodb/bin/mongod -f /data/mongodb/27017.conf

    登录后关闭

    /usr/local/mongodb/bin/mongo 127.0.0.1:27010

    > use admin

    switched to db admin

    > db.shutdownServer()

    直接关闭

    kill <mongod process ID>

    5、给admin授权并登录

    shell> use admin;

    shell> db.createUser({user:'admin',pwd:'admin123', roles:[{role:'root', db:'admin'}]});

    修改admin密码

    > db.changeUserPassword('admin','123456')

    登录:

    /usr/local/mongodb/bin/mongo 127.0.0.1:27017 -u admin -p 123456 --authenticationDatabase admin

  • 相关阅读:
    C# 实现类库并调用
    C# pictureBox.Image获得图片的三种方法
    C# 指针使用总结
    C++ 怎样让函数返回数组
    C# 枚举与位枚举(Enum)
    Labview调用C#动态链接库dll
    C# partial 作用
    C# Internal关键字小结
    C# => 运算符
    C# 中 ??、 ?、 ?: 、?.、?[ ]
  • 原文地址:https://www.cnblogs.com/qiansm/p/15241212.html
Copyright © 2011-2022 走看看