安装mogodb

2019-02-23  本文已影响0人  魔童转世

创建/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

运行以下命令安装最新版的mongodb:

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
上一篇下一篇

猜你喜欢

热点阅读