CentOS 7 安装MongoDB

1、配置yum源

创建/etc/yum.repos.d/mongodb-org-4.0.repo文件,编辑内容如下:

[mongodb-org-4.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc

安装

sudo yum install -y mongodb-org

配置mongod.conf允许远程连接:

$ vim /etc/mongod.conf

# Listen to all ip address
bind_ip = 0.0.0.0

启动mongodb:

sudo service mongod start

创建管理员用户:

$ mongo
>use admin
 db.createUser(
  {
    user: "myUserAdmin",
    pwd: "abc123",
    roles: [ { role: "userAdminAnyDatabase", db: "admin" }, "readWriteAnyDatabase" ]
  }
 )

启用权限管理:

$ vim /etc/mongod.conf

#security 
security:
  authorization: enabled

重启mongodb:

sudo service mongod restart

 

mongoDB可视化工具Robo 3T

1:下载安装和使用Robo 3T:https://robomongo.org/download

上一篇:mogodb 可随意复制的简单配置


下一篇:linux下service mongod start启动报错