Skip to content

Enable security authentication for Mongodb Server access

Notifications You must be signed in to change notification settings

thotho19/mongodb_security

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

Really, never do so. No authentication means inviting everyone out there to enter your databases, seize everything and potentially ransom you for your data.

User Administrator Procedures

  1. Start MongoDB without access control.
mongod --port 27017 --dbpath /var/lib/mongodb
  1. Connect to the instance.
mongo --port 27017
  1. Create the user administrator.
use admin
db.createUser(
  {
    user: "myUserAdmin",
    pwd: passwordPrompt(), // or cleartext password
    roles: [ { role: "userAdminAnyDatabase", db: "admin" }, "readWriteAnyDatabase" ]
  }
)
  1. Configurationn and Re-start the MongoDB instance with access control.
    config
1- C:\Program Files\MongoDB\Server\4.4\bin -> open mongodb.cfg file -> seek for security -> eanble the security 
2- security:
    authorization: enabled
3- save and exit

Restart

Control Panel -> administrative Tools -> services -> seek for MongoDB Server(MongoDB) -> Restart the service
  1. Connect and authenticate as the user administrator.
mongo --port 27017  --authenticationDatabase "admin" -u "myUserAdmin" -p "myPassword"

Usefell commands

command the value
db.dropUser("mynewuser") drops the administrator user from the database(disable security is required)

About

Enable security authentication for Mongodb Server access

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published