CentOS 7 安装MongoDB详细步骤
创建/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
大功告成!
本文来自博客园,作者:YanceDev,转载请注明原文链接:https://www.cnblogs.com/yance-dev/p/10453121.html