title: How to setup MongoDB with username and password
body: <p>I am setting up <code>mongo db</code> in <code>ubuntu 18.04</code>. I have installed it using the commands given on their <a href="https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/" rel="nofollow noreferrer">page</a>. After the installation, I have downloaded <code>NoSqlBooster</code> and have connected to Mongo server using localhost.</p>
  <p>I have created a database named <code>RIPE</code> and have also added some collections and test documents. At this point, I have also created some read users for <code>RIPE</code> so that I can share read user credentials with my colleagues for them to use it. I do not want them to make changes so just want to give them read access. Below is the screenshot</p>
  <p><a href="https://i.stack.imgur.com/ZJydK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZJydK.png" alt="enter image description here" /></a></p>
  <p>My first question is, I have added <code>ttread</code> user in <code>RIPE</code> db which we can see in above image but why its showing it outside of <code>RIPE</code> db as well?</p>
  <p>My 2nd question is, how can I make users to directly connect to <code>RIPE</code> db. In nosqlbooster, when I am connecting to localhost, I have mentioned <code>AuthDB</code> as <code>RIPE</code> as shown below:</p>
  <p><a href="https://i.stack.imgur.com/Wmsdd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Wmsdd.png" alt="enter image description here" /></a></p>
  <p><a href="https://i.stack.imgur.com/Q8eNm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Q8eNm.png" alt="enter image description here" /></a></p>
  <p>and when it connects it shows other db as well like, <code>admin</code>, <code>config</code>, <code>local</code>.</p>
  <p>Last question, while setting up the mongodb how can I add a username and password because any user can connect to localhost without username and password. So what is the best way to setup security.</p>
  <p>Thanks</p>