MongoDB安装手册 MongoDB Installation Guide

Installation on Linux

Linux Version

CentOS Linux release 7.6.1810 (Core)

Reference

https://docs.mongodb.com/manual/tutorial/install-mongodb-on-red-hat/

Install MongoDB Community Edition

Note that the MongoDB here is installed by default settings.
Make sure that the proxy for yum repository has been configured and the root permission has been accessed.

step1: Configure the package management system (yum). Create a /etc/yum.repos.d/mongodb-org-4.0.repo file so that you can install MongoDB directly using yum:

[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

step2: Install the MongoDB packages. To install the latest stable version of MongoDB, issue the following command:

yum install -y mongodb-org
Run MongoDB Community Edition

1. Start MongoDB

You can start the mongod process by issuing the following command:

service mongod start

2. Verify that MongoDB has started successfully

You can verify that the mongod process has started successfully by checking the contents of the log file at /var/log/mongodb/mongod.log for a line reading.

[initandlisten] waiting for connections on port <port>

You can optionally ensure that MongoDB will start following a system reboot by issuing the following command:where is the port configured in /etc/mongod.conf, 27017 by default.

chkconfig mongod on

3. Stop MongoDB

As needed, you can stop the mongod process by issuing the following command:

service mongod stop

4. Restart MongoDB.

You can restart the mongod process by issuing the following command:

service mongod restart

5. Begin using MongoDB.

Start a mongo shell on the same host machine as the mongod. You can run the mongo shell without any command-line options to connect to a mongod that is running on your localhost with default port 27017:

mongo

MongoDB GUI Client

Like Redis Desktop Manager, MongoDB client is used for connect to MongoDB service and visualize the mongo command lines.
在这里插入图片描述
Click ‘Connect to’ and enter the mongo server’s IP, then click ‘connect’:
在这里插入图片描述
However, the first-time connection usually fail because the mongo service refuses the remote access by default. The solution is to modify the bind_ip in mongod.conf file.

vim /etc/mongod.conf

replace the bindIP from 127.0.0.1 to 0.0.0.0:
在这里插入图片描述

remember to restart the mongodb service:

service mongod restart

Now the connection is successful:
在这里插入图片描述

  • 15
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 9
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值