I'm trying to connect to MongoDB using mongosh
on the localhost, and when I type this command:
mongosh --port <PORT> <DATABASE_NAME> -u <USERNAME> -p <PASSWORD>
this what I got:
...
MongoServerError: Authentication failed.
I'm trying to connect to MongoDB using mongosh
on the localhost, and when I type this command:
mongosh --port <PORT> <DATABASE_NAME> -u <USERNAME> -p <PASSWORD>
this what I got:
...
MongoServerError: Authentication failed.
To solve this problem add this option and argument to your mongosh
command:
--authenticationDatabase admin
So the full command will be like that:
mongosh --port <PORT> <DATABASE_NAME> -u <USERNAME> -p <PASSWORD> --authenticationDatabase admin