Centos7下使用yum安装mongoDB
- 2020-11-09 09:22:00
- 六月
- 转贴 2479
安装步骤
1.配置MongoDB的yum源 /etc/mongodb-org-4.2.repo
[mongodb-org-4.2]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.2/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.2.asc
2.安装命令:
yum -y install mongodb-org
3.修改配置文件
vi /etc/mongod.conf
把bindIP改成 0.0.0.0所有的机器都可以访问
4.启动MongoDB
启动mongodb :
systemctl start mongod.service
停止mongodb :
systemctl stop mongod.service
查到mongodb的状态:
systemctl status mongod.service
5.启动Mongo shell
mongo
查看数据库
show dbs
重启mongodb使修改生效:
systemctl restart mongod.service
mongodb报错1: connecting to:mongodb://127.0.0.1:27017. connect failed
原因: 是没有执行mongod,就直接执行mongo,才会报错
参考: https://blog.csdn.net/xgs736214763/article/details/78505856