I have installed MongoDB in my computer. I did't define any password and username for the installation. I can see everything with Robo 3T. Now I want to protect my database. I have tried to set authentication for the database. I followed https://docs.mongodb.com/manual/tutorial/enable-authentication/ . It did not work. I still can reach mongodb with robo 3t and see all information. I have also tried to start mongodb with --auth parameter. I have define a configuration file looks like And for starting mongodb
mongod -f C:\mongodb\conf\mongodb.conf
Mongodb has been started but, it did not ask any pass. And I can save simple data with Postman without authentication.
What I want to do:
- Protect my database against Robo 3t. :))
- I dont want to save any data without auth.
- Building Nodejs connection string that include pass like mysql://root:password@localhost:port/dbName
Here is my Nodejs index.js code
PS: I am very new in Nodejs and Mongodb.