I am running on a Ubuntu Linux system (Focal); I have a mongo (version 5.0.3) database with authentication enabled. I cannot find a command line that will drop me into the mongo shell for the database I want. Could someone please lend me a clue?
If I issue the command mongosh -u mongoAdmin -p '<password>' mongodb://127.0.0.1/
I get into the mongo shell using the test database. To get to my database db-name, I need to issue the command use db-name
.
If I issue the command mongosh -u mongoAdmin -p '<password>' mongodb://127.0.0.1/db-name
I get an error message:
Current Mongosh Log ID: 617d0f78622b00d5095d474d
Connecting to: mongodb://127.0.0.1/db-name?directConnection=true&serverSelectionTimeoutMS=2000
MongoServerError: Authentication failed.
Users I have configured in the admin database:
[
{
_id: 'admin.mongoAdmin',
userId: UUID("6dbdd918-02c4-4000-b5e4-ff59db9f86ed"),
user: 'mongoAdmin',
db: 'admin',
roles: [ { role: 'userAdminAnyDatabase', db: 'admin' } ],
mechanisms: [ 'SCRAM-SHA-1', 'SCRAM-SHA-256' ]
}
]