MongoDB Remote access configuration steps in detail

  • 2020-06-03 08:43:19
  • OfStack

This article is about MongoDB remote access configuration, so without further ado, let's look at the detailed steps.

1. First, modify the configuration file of mongodb to listen to all ip

Edit file: /etc/mongodb.conf

The revised content is 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
 
# The remote connection 
 
/usr/local/mongodb/bin/mongo 127.0.0.1/admin -u username -p password

4. Add user access to a database


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

5. Delete users


db.removeUser('username')

conclusion

The above is all about the remote access configuration of mongodb. I hope the content of this article can bring you certain help in your study or work. If you have any questions, you can leave a message to communicate.


Related articles: