1

I'm running a local test environment with MongoDB on localhost. I can connect to it via Compass and command line using a root user. However, I created another user on my working database (not the admin database). I can connect using command line: mongo localhost/[my db name] -u[my username] but Compass times out (mongodb://[my username]:[my password]@localhost/[my db name])

When connecting via command line, I can issue use [my db name] then db.[collection name].find() and I get the correct results.

What am I doing wrong?

Ryan Griggs
  • 2,457
  • 2
  • 35
  • 58

1 Answers1

0

I was facing the same issue. Use authSource=yourDBName at the end of your connection string. Hence your connection string would be like:

mongodb://[my username]:[my password]@localhost/[my db name]?authSource=[my db name]
BSP
  • 735
  • 1
  • 10
  • 27
Hamza
  • 530
  • 5
  • 27