search

Home  >  Q&A  >  body text

Database - How to set username and password for mongodb remote connection?

请输入代码I followed this tutorial to set up:
http://www.111cn.net/database...

In fact, I just commented out the bind_ip = 0.0.0.0 in the configuration file..
But the pain came:
mongo 服务器的ip:27017

I can actually connect!! And no username or password is required!!!!!!
I have been looking for a long time but I can’t find an answer that is really useful!
Is there any expert who knows the answer?
How to make remote access to my database require a password, that is, mongo 服务器的ip:27017This way direct access cannot be accessed

Additional instructions

Follow this tutorial:
https://docs.mongodb.com/manu...
After I added the administrator account,
the prompt was that it was successfully created~~ But when I logged in, I found that I still logged in directly!!!

This is too unsafe~ You can log in to my database if you know my IP address~~

Added again

After google, I found that the verification may not be turned on. However, the tutorials I saw on the Internet were basically not 3.0 tutorials
. They all said to turn on mongodb.conf in auth = true, but mongodb 3.0 does not have this option. Where should I modify it?

世界只因有你世界只因有你2788 days ago722

reply all(2)I'll reply

  • PHPz

    PHPz2017-05-02 09:24:59

    Is it 3. /etc/mongod.conf
    Modify `bindIp : 0.0.0.0 //Allow all IP links, external links
    Then add permissions to the database you need to be remote, such as:
    use xxxx;db.createUser({user:"jimb55",pwd:"123456",roles:[{"role":"readWrite","db":"xxxx"}] }) Then exit to exit the client
    Kill the related processes killall mongodvi /etc/mongod.conf
    修改 `bindIp : 0.0.0.0 //允许所有IP链接,外链
    然后对你需要远程的数据库添加权限,如:
    use xxxx;
    db.createUser({user:"jimb55",pwd:"123456",roles:[{"role":"readWrite","db":"xxxx"}]})
    然后exit退出客户端
    杀掉相关的进程killall mongod
    然后开启验证模式
    mongod -f /etc/mongod.conf --fork --auth
    你可以用Robomongo.exe远程登录试试
    Robomongo.exeThen turn on the verification mode

    mongod -f /etc/mongod .conf --fork --auth 🎜You can use Robomongo.exe to log in remotely. The usage of Robomongo.exe is in the link given. Description 🎜

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-05-02 09:24:59

    Modificationmongod.conf

    security:
      authorization: enabled

    mongodb is really poorly designed, I plan to change to RethinkDB

    reply
    0
  • Cancelreply