CentOS 7.x 安装MongoDB

配置MongoDB的yum源

vim /etc/yum.repos.d/mongodb-org-3.4.repo
#添加以下内容:
[mongodb-org-3.4]  
name=MongoDB Repository  
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.4/x86_64/  
gpgcheck=1  
enabled=1  
gpgkey=https://www.mongodb.org/static/pgp/server-3.4.asc
 
 
 
 
yum makecache

 

安装MongoDB

yum -y install mongodb-org

查看mongo安装位置 :

whereis mongod

    查看修改配置文件 :
vim /etc/mongod.conf
 
systemctl start mongod.service 启动mongodb
systemctl stop mongod.service 停止
systemctl status mongod.service 查到mongodb的状态
 
关闭firewall:
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
 启动Mongo shell
命令:
mongo
查看数据库:
show dbs

设置mongodb远程访问:

编辑mongod.conf注释bindIp,并重启mongodb.(这句配置代表只能本机使用,所以需注释)
vim /etc/mongod.conf
重启mongodb使修改生效:
systemctl restart mongod.service

猜你喜欢

转载自www.cnblogs.com/seau/p/12175399.html