Академический Документы
Профессиональный Документы
Культура Документы
use cool_db
db.createUser({
user: 'ian',
pwd: 'secretPassword',
roles: [{ role: 'readWrite', db:'cool_db'}]
})
Look for the net line and comment out the bindIp line under it, which is
currently limiting MongoDB connections to localhost:
Warning: do not comment out the bindIp line without enabling authorization.
Otherwise you will be opening up the whole internet to have full admin access to all
mongo databases on your MongoDB server!
# network interfaces
net:
https://ianlondon.github.io/blog/mongodb-auth/ 1/8
11/18/2020 How to connect to your remote MongoDB server – Ian London's Blog
port: 27017
# bindIp: 127.0.0.1 <- comment out this line
Scroll down to the #security: section and add the following line. Make sure to
un-comment the security: line.
security:
authorization: 'enabled'
Make sure you can still log in with mongo while ssh’d into the box.
Now you can read and write within the cool_db database from your laptop without
ssh !
client = pymongo.MongoClient("mongodb://ian:secretPassword@123.45.67.89/cool_db") #
https://ianlondon.github.io/blog/mongodb-auth/ 2/8
11/18/2020 How to connect to your remote MongoDB server – Ian London's Blog
db = client.cool_db
How to connect to your remote MongoDB server was published on May 23, 2016.
Thanks,
Giri.
△ ▽ • Reply • Share ›
△ ▽ • Reply • Share ›
Before your post, I've tried to connect for three hours. Thank
you.
△ ▽ • Reply • Share ›
Ex.
mongod --dbpath=data --bind_ip_all
😁😁😁
△ ▽ • Reply • Share ›
© 2017 Ian London. Powered by Jekyll using the Minimal Mistakes theme.
https://ianlondon.github.io/blog/mongodb-auth/ 8/8