SyntaxFix
Write A Post
Hire A Developer
Questions
🔍
[authentication] How to secure MongoDB with username and password
Home
Question
How to secure MongoDB with username and password
These steps worked on me:
write mongod --port 27017 on cmd
then connect to mongo shell : mongo --port 27017
create the user admin : use admin db.createUser( { user: "myUserAdmin", pwd: "abc123", roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] } )
disconnect mongo shell
restart the mongodb : mongod --auth --port 27017
start mongo shell : mongo --port 27017 -u "myUserAdmin" -p "abc123" --authenticationDatabase "admin"
To authenticate after connecting, Connect the mongo shell to the mongod: mongo --port 27017
switch to the authentication database : use admin db.auth("myUserAdmin", "abc123"
Examples related to
authentication
•
Set cookies for cross origin requests
•
How Spring Security Filter Chain works
•
What are the main differences between JWT and OAuth authentication?
•
http post - how to send Authorization header?
•
ASP.NET Core Web API Authentication
•
Token based authentication in Web API without any user interface
•
Custom Authentication in ASP.Net-Core
•
Basic Authentication Using JavaScript
•
Adding ASP.NET MVC5 Identity Authentication to an existing project
•
LDAP: error code 49 - 80090308: LdapErr: DSID-0C0903A9, comment: AcceptSecurityContext error, data 52e, v1db1
Examples related to
mongodb
•
Server Discovery And Monitoring engine is deprecated
•
Avoid "current URL string parser is deprecated" warning by setting useNewUrlParser to true
•
MongoNetworkError: failed to connect to server [localhost:27017] on first connect [MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017]
•
Failed to auto-configure a DataSource: 'spring.datasource.url' is not specified
•
Failed to start mongod.service: Unit mongod.service not found
•
db.collection is not a function when using MongoClient v3.0
•
MongoError: connect ECONNREFUSED 127.0.0.1:27017
•
MongoDB: How To Delete All Records Of A Collection in MongoDB Shell?
•
How to resolve Nodejs: Error: ENOENT: no such file or directory
•
How to create a DB for MongoDB container on start up?