Linux使用rpm安装MongoDB

一,创建文件夹

cd /usr/local
mkdir mongodb

二,下载rpm文件

cd mongodb
wget https://repo.mongodb.org/yum/redhat/7/mongodb-org/7.0/x86_64/RPMS/mongodb-org-mongos-7.0.5-1.el7.x86_64.rpm
wget https://repo.mongodb.org/yum/redhat/7/mongodb-org/7.0/x86_64/RPMS/mongodb-org-server-7.0.5-1.el7.x86_64.rpm
wget https://downloads.mongodb.com/compass/mongodb-mongosh-2.1.5.x86_64.rpm

三,安装

rpm -ivh mongodb-org-mongos-7.0.5-1.el7.x86_64.rpm
rpm -ivh mongodb-org-server-7.0.5-1.el7.x86_64.rpm
rpm -ivh mongodb-mongosh-2.1.5.x86_64.rpm

四,启动服务

systemctl start mongod.service

五,进入命令行

mongosh

六,开启账户和pass

show dbs;
use admin
#创建账户
db.createUser({user: 'root', pwd:'TdLLQd689', roles:[{role: 'root', db: 'admin'}]});
#编辑配置文件
vi /etc/mongod.conf
#修改节点,保存退出
security:
#    keyFile: /data1/mongodb/key/keyfile
    authorization: enabled
#重启服务
systemctl restart mongod.service
#通过创建的用户登录数据库
mongosh mongodb://127.0.0.1:27017/admin -u root -p 'TdLLQd689'

七,进阶优化,请参考

https://blog.51cto.com/wujianwei/4939772

Leave a Comment

Your email address will not be published.

*

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据