[SERVER-31790] Prompt for username and password Created: 01/Nov/17  Updated: 07/Dec/17  Resolved: 02/Nov/17

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Question Priority: Minor - P4
Reporter: Abhishek [X] Assignee: Mark Agarunov
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:

 Description   

I have an issue in mongoDb,

When I am connecting to the mongodb server it never prompts me for the username and password even I have setup an id and password and enabled security authorization in the /etc/mongod.conf file. After I enter the server by typing "mongo" it shows me the available databases but does not let me perform any operations on them.

I want it to ask me for the id and the password whenever I type "mongo" to start the mongoDb server. How should I go about it. I don't want to manually enter the command

mongo -u ******* -p --authenticationDatabase admin
mongo -u ******* -p ********



 Comments   
Comment by Mark Agarunov [ 02/Nov/17 ]

Hello Abhi,

Thank you for the report. You can use the mongorc.js file to execute commands when the shell starts. For example, adding the following to your mongorc.js file can be used to authenticate when you run mongo:

db = connect("<hostname>:<port>/<database name>");
db.getSiblingDB("<authentication database>").auth("<username>", "<password>");

Please note that SERVER project is for reporting bugs or feature suggestions for the MongoDB server. For MongoDB-related support discussion please post on the mongodb-user group or Stack Overflow with the mongodb tag. A question like this involving more discussion would be best posted on the mongodb-user group.

Thanks,
Mark

Generated at Thu Feb 08 04:28:12 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.