setup Auth in mongodb
Jan 24, 2017
鑑於最近 mongodb 的裸奔事件頻傳
我也來設定一下我的 mongodb
順便玩一下 MongoHub for Mac 這套 GUI
以前 mongodb 的設計呢
是只要建立了 user 就會啟用 auth
但新版的不是這樣
記錄一下我這次 2.6.10 版的設定情況
首先
在預設的設定下(listening local only)123456789$ mongo> use admin> db.createUser({user: "root",pwd: "password", roles: [{ role: "userAdminAnyDatabase", db: "admin" }]})
然後
|
|
加上 server 的 public ip 到 bind_ip
將 auth = true
給 uncomment
You have to uncomment
auth = true
hereto make server running with Authentication
not just create users
也就是如果你照以前的作法只建了 user
那你就成了裸奔的 mongodb 管理者
if u did,
you will be one of mongodb admin
who putting naked servers straight onto the Internet 😅
最後
記得1$ sudo service mongodb restart
話說, 這裡還有一個坑~
if you type
service mongod start
on DigitalOcean buildit will always complain about
No such config file
…😫但好像有一些 build 是
mongod
不是 mongodb