0

Sorry if this question sounds stupid, but I can't find this anywhere on the internet. I created a user in MongoDB in the MongoShell.

use admin
db.createUser({user: "user" , pwd: "test", roles: [  "userAdminAnyDatabase","readWriteAnyDatabase" ]})

I used the MongoDB compass to login. It works, I can see every database and collections. But I wanted to login using Mongoose (A wrapper for MongoDB) for my NodeJS app. In the Mongoose version 5.4.19 documentation, it said that you can use mongoose.connect('mongodb://username:password@host:port/database?options...'); So I did this: mongoose.connect('mongodb://user:test@localhost:27017/walnutz'); but it didn't work. I also tried doing this: mongoose.connect('mongodb://user:test@127.0.0.1:27017/walnutz'); but that didn't work as well. So does anyone have the answer to fix this issue?

Felix Isaac
  • 312
  • 6
  • 13

0 Answers0