mongo官方企业版安装及数据库授权使用

通过安装.deb包的方式,系统是Ubuntu 16.04

1. Import the public key used by the package management system.(导入包管理系统所使用的公钥。)

 sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4

2. Create a /etc/apt/sources.list.d/mongodb-enterprise.list file for MongoDB.(为MongoDB创建一个/etc/apt/sources.list.d/mongodb-enterprise.list 文件)【我的是Ubuntu 16.04】

echo "deb [ arch=amd64,arm64,ppc64el,s390x ] http://repo.mongodb.com/apt/ubuntu xenial/mongodb-enterprise/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-enterprise.list

3. Reload local package database.(重载本地包数据库)

sudo apt-get update

4. Install the MongoDB Enterprise packages.(安装Mongodb企业版包)

sudo apt-get install -y mongodb-enterprise

5.Pin a specific version of MongoDB Enterprise.(防止无意的更新)

echo "mongodb-enterprise hold" | sudo dpkg --set-selections
echo "mongodb-enterprise-server hold" | sudo dpkg --set-selections
echo "mongodb-enterprise-shell hold" | sudo dpkg --set-selections
echo "mongodb-enterprise-mongos hold" | sudo dpkg --set-selections
echo "mongodb-enterprise-tools hold" | sudo dpkg --set-selections

 

启动mongod 服务器

mongod

停止monogd服务器

mongod --shutdown

连接mongod服务器

    mongo

 

对固定数据库进行授权

先以 mongod的方式启动服务

use rgc #进入到rgc数据库

db.createUser({user:'rgc',pwd:'dfdf',roles:[{role:'readWrite',db:'rgc'}]}) #添加拥有rgc数据库读写权限的用户

 

再以 mongod --auth重启服务

db.auth('rgc','dfdf') #进行授权,返回1 的话,说明成功认证,有对db:'rgc'的读写权限

 

配置文件位置:/etc/mongod.conf

可以通过 mongod -f /etc/mongod.conf 运行服务

posted @ 2018-10-19 15:56  RGC  阅读(398)  评论(0编辑  收藏  举报