ITPub博客

首页 > 数据库 > > UBUNTU18.04安装mongodb

UBUNTU18.04安装mongodb

作者:浪花小雨滴 时间:2020-05-12 11:47:20 0 删除 编辑

安装

导入公钥

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5

创建源列表文件MongoDB

echo "deb [ arch=amd64 ] Index of ubuntu bionic/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb.list

安装

sudo apt install libcurl3

更新系统

sudo apt update

安装MongoDB Server

sudo apt install mongodb-org

管理mongoDB Server

sudo systemctl enable mongod  # 加入mongod服务
sudo systemctl start mongod   # 开启mongod服务
sudo systemctl stop mongod  # 停止mongod服务

安装完成

配置

创建超级管理员

db.createUser(
  {
    user: "admin",
    pwd:"你的密码",
    roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
  }
)  

登陆

db.auth("admin","ZZBrap8WrJRjsyZx")

创建其他用户

use test  # 切换至test数据库
db.createUser(
  {
    user: "myTester",
    pwd: "xyz123",
    roles: [ { role: "readWrite", db: "test" }
  }
) 

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/31537575/viewspace-3165736/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2018-05-16

  • 博文量
    4259
  • 访问量
    40022