Detailed description of MongoDB remote access configuration steps

Time:2019-10-10

This article is about MongoDB remote access configuration. Let’s go straight to the detailed steps.

1. First, modify the configuration file of mongodb so that it can monitor all external IPS

Edit documents: /etc/mongodb.conf

The revised contents are as follows:


  bind_ip = 0.0.0.0

  port = 27017

  auth=true

2、 /etc/init.d/mongodb restart

3. Connection

# Local connection

/usr/local/mongodb/bin/mongo
 
# Remote Connection
 
/usr/local/mongodb/bin/mongo 127.0.0.1/admin -u username -p password

4. Adding user access rights to a database


 db.addUser('user','pwd')
 db.auth('user','pwd')

5. Delete Users


db.removeUser('username')

summary

The above is all about the mongodb remote access configuration. I hope that the content of this article can bring some help to everyone’s study or work. If you have any questions, you can leave a message to exchange.